Spanish Italian
17433 Users    

An MCU-resident rapid prototyping and education environment. Including zigbee wireless

  Download PDF version of the Article

The pedal sub routine’s responsibility is to move the pedal. Okay. So, first thing we’re going to do is we’re going to clear the old pedal position. The pedal is 3 pixels wide. So, we have 3JM clear statements. Then, we’re going to compute the new pedal position. We do that by using the tilt sensor, the analog to digital converter, the variable, connect it to the accelerometer. The rest position of the accelerometer is half scale at 1.65 volts. The analog to digital converter reports values in miilivolts. So, we’re going to subtract 1650 and divide by a 100 to get a value like minus 5 to 5 to figure out how many pixels to move the pedal by, and then we’re going to add that to the current pedal position.

If the pedal position went out of bounds, we’re going to bring the pedal position back into bounds. It’s a 16 by 5 LED matrix. And finally we’re going to set the new pedal position here just by displaying the 3 pixels at the new position. That’s the end of the sub routine that’s running every 50 milliseconds asynchronous managing the pedal position while the main program is managing the ball position. So, all we have left now is the loose sub routine. The loose sub routine basically, is called when the user looses the game. First thing we want to do is we don’t want to be displaying the pedal while we’re you know scrolling the message you lose and playing the music. So, we mask the virtual timer #1 so that we stop calling the pedal sub routine. We’re going to unmask that at the end so that we can start calling the paddle sub routine every 50 milliseconds again for the new game. Then we clear the display, clear everything that’s on there, we scroll you lose off of it, then we play an audio scale. We start out by saying let audio equal 5000. Boom, there’s a 5000 hertz tone going through the buzzer. Then we do a loop that basically just decreases that by one note every 50 milliseconds until we reach 400 hertz. Then we turn the audio off and when we scroll this message you lose that was done asynchronously. So, we’re going to wait for that to finish scrolling off the screen by scrolling another message behind it and then unmask the timer interrupt to allow the paddle manipulation to continue. And then returning from the sub routine, and then we’re going to break out of the inner wore loop, return to the outer wire loop and start a new game. That’s basically pong in basic.

Okay. Let’s do a quick wireless demo. We have got the badge board attached to the 132OX RFC card. You will notice a couple of things are different here. Basically, the MCU talks to the Zigbee wireless chip through QSPI and QSPI is actually multiplex on the exact same pins that are used for driving the LED. So the operating system detects that Zigbee chip is there and doesn’t send LED traffic to these pins but there is QSPI traffic on the pins which is now visible on the LEDs. Anyway but basically, we have got a command prompt. We are talking about board. We are nodeid7 Zigbee nodeid 7. We have got another board over here that is a, it’s an Ethernet board, 52233, also running the same operating system. And he’s running Zigbee nodeid3. So what we’re going to do is we’re going to connect to him remotely. So we don’t even have an Ethernet attached cable attached to this board. We’re now wirelessly talking to the Ethernet chip and we’re going to write a small program here. 10 dim led as pin, dtin 0 for analogl output and what that basically does is that creates a variable bound to pin dtin0 where they have this main LED and it configures the pin for analog output. Basically, pulse width modulation. So we’re going to vary the duty cycle on the PWM and that’s going to change the intensity of the LED. 20 while 1 do 30, endwhile. Wait a second. That’s an infinite loop. Yes, it’s an infinite loop. Anyway, it’s an infinite loop. Basically, this is only half the program, right, we’re going to write half the program on nodeid3. We’re going to write the other half of the program on nodeid7. Basically this node, nodeid3 is just going to sit there forever with a variable bound to a pin and that variable is going to be modified from the other node. So we’re going to run the infinite loop, not very exciting, we’re going to press control D, to return back to the other node. We’re going to verify we’re there and we’re back on nodeid7.

And now we’re going to write actually we might even have it already, hah, look at that, there’s a program there already. This program basically, is going to run on nodeid7 and the first thing he does is he dimensions a variable named LED, saying name is on the other node. And he says you know what, this variable isn’t here. It’s not present on my node. It’s actually remote on nodeid3. That’s what he is saying here. Dim LED as remote on nodeid3. So, anytime we modify that variable, what’s going to happen is basically, we’re going to send out a Zigbee request to the other node and he’s going to modify his variable and his variable happens to be bound to his pin where the LED is. So, we’re going to create a remote LED dimmer. Then we go through the same work that we did before. Basically, we declare sleep and tilt to talk to the accelerometer and then we run this little tiny loop which basically just says every hundred milliseconds, take the tilt value and assign it to the LED that’s going to go wireless over to the other node and so as you tilt this board, the other board’s LED is going to respond with a varying intensity as brightness. So, we can run that and we pick up this guy. We tilt him and sure enough, the LED on the other board is changing intensity as we move this guy’s accelerometer. Anyway, so that’s pretty cool. That’s a you know 3 lines on the other node and 8 lines here, 11 line wireless embedded system control program. Obviously, we didn’t save them. We didn’t set them to auto run. But basically, you know it takes less lines than that to do an on/off switch, you know a wireless switch.

Okay. What I’m showing you now. Okay, no trip to my house is complete without a visit to my toaster oven. My toaster oven has a thermocouple and solid state real here. And basically, I’m running a 52221 down here on this little tiny circuit board that plugs right into a solderless breadboard and we’re running the operating system. We’re running Basic and we have got a basic control program that basically controls the toaster oven. I have got a Zigbee wireless board on top and a little solderless breadboard there and a battery and basically we can log in and we can re-flow printed circuit boards in our toaster oven.

So, we have seen a lot today. Basically, we have seen my dream come true. We have got a real honest to goodness computer on a chip, not just a programmable chip. A computer on a chip. It’s got an operating system, editor, compiler, debugger, everything’s interactive. You can log in via USB or Ethernet or even Zigbee. You plug a little card on the back. You have got a Zigbee wireless control nodes. It’s got a little CR2 battery holder on the bottom. That’s a 52221 running there. Just like the 51JM28, a little bit more expensive, a little bit bigger. But basically, you have got everything that you need in order to put of these guys in your attic or in your yard or anywhere you want. You can write a program on it without reading a 500 page reference manual. You want to use the peripherals, you want to use an analog to digital converter, one line of code. You want to use a timer, one line of code. You want to use pulse width modulation or frequency generation or digital input or output, one line of code. Your program no longer is responsible for managing all the peripherals.

All it does is link them together. You want to do wireless. You can talk between one of these nodes and another node. You can you know or log in from one to the other. They can talk to each other while they’re running programs. You can do your remote light switch, remote LED device everything with handfuls of lines of code. My goal is to bring embedded systems development to the masses, to the people who don’t want to read the 500 page reference manual which by the way isn’t me, I love reading that 500 page reference manual. But, not every body does, right. I want to bring embedded systems to high schools. I want to bring embedded systems to reach researchers running in labs who have data acquisition that they need to do or data control that they need to do. You know the guy who’s got his weather station sitting outside his window and he doesn’t want to run a wire to it.

I want to bring embedded systems everywhere and you know what, with these new Freescale processors, the 51JM128, the 52221, the 52233, there’s no excuse not to do this. We have got everything we need right there on the processor. All we have to do is make it a little easier to use, expose it to the right user, you know give him that interactive programmable computer on a chip. Thank you very much.

So, two last things. The first thing is, yeah you know the basic is really cool. It might be a might sweeter, get things up and running you know rapid prototyping or something like that. But you know I don’t really think that I want to ship something with basic. I don’t want to keep it basic. You know can I help? Well, yes. This leads into the last thing and the last thing is where do you get more information? Right. It’s all on the web at www.cpustick.com. It’s kind of like memory stick, only it’s a cpu stick. You plug in your USB. You can write your program. You could save your program. You could figure what you put in your pocket, anything you want.

On that website there are all sorts of things. There’s versions of the operating system for the 51JM128, and specific ones for the badge board that comply to the badge board boot loader requirements. There’s versions for the 5221 that use USB, for the 52233 using Ethernet. There is also a skeleton source code project there and what that is basically is all the initialization code used by the operating system as well as all of the pin manipulation and peripheral manipulation code including flash memory, including Zigbee wireless, including you know timers, you know pulse width modulation, frequency generation, analog to digital converters, digital I/O, everything. Its all there basically in source code form in the skeleton projects so that once you have got your program written and running in basic, if you want to, you can actually translate it into C and you can bind in all the exact same low level code used by the operating system and make a C program. Anyway, basically what you’re seeing out on the web, is my dream come true and I think we got exciting things in store for us here and these processors are just going to get better and better and better and I’m happy to be here with it. Anyway, thank you very much.

Read also: CPUStick

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
1 + 11 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

Who's new

  • christiank79
  • agabor
  • fabriziopd
  • irenix
  • pepershoe
  • raghun14
  • andreaspousette
  • rilhyk
  • thientruong
  • snaku

Who's online

There are currently 0 users and 29 guests online.