SX/B 16 channel PWM and/or SERVO controller
Here it is. A 16 channel PWM controller using the SX28 written in SX/B.
Please ask if you any questions.
If there is enough interest I could make a PCB for the project.
I set the baud rate to 2400 so BS1 user can use it. (EFX Prop-1 ?)
Note that it generates true "duty cycle" PWM so you can use it for motor control.
The PWM rate is about 195 Hz so there won't be any flicker for LED use.
Edit: PWM_SERVO16.SXB can control PWM or servos. The Servo control is a little rough (20uSec steps), this means that 50=Hard left(1.0mSec), 75=Centered(1.5mSec) and 100=Hard right. If your continuous servos are adjusted properly you should be okay.
Enjoy, Bean.
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95 http://www.parallax.com/detail.asp?product_id=30012
Product web site: www.sxvm.com
"It's not getting what you want, it's wanting what you've got."
Post Edited (Bean (Hitt Consulting)) : 5/18/2005 1:22:25 AM GMT
Please ask if you any questions.
If there is enough interest I could make a PCB for the project.
I set the baud rate to 2400 so BS1 user can use it. (EFX Prop-1 ?)
Note that it generates true "duty cycle" PWM so you can use it for motor control.
The PWM rate is about 195 Hz so there won't be any flicker for LED use.
Edit: PWM_SERVO16.SXB can control PWM or servos. The Servo control is a little rough (20uSec steps), this means that 50=Hard left(1.0mSec), 75=Centered(1.5mSec) and 100=Hard right. If your continuous servos are adjusted properly you should be okay.
Enjoy, Bean.
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95 http://www.parallax.com/detail.asp?product_id=30012
Product web site: www.sxvm.com
"It's not getting what you want, it's wanting what you've got."
Post Edited (Bean (Hitt Consulting)) : 5/18/2005 1:22:25 AM GMT
Comments
Thank you for posting this. I havn't worked with the SX parts yet, but this sneak peak is very helpful. It may be that I will be able to get the SX tool kit early this summer.
I am currently using a dedicated BS2 OEM to do PWM on an h-bridge for two DC gearmotors. Don't use serial though, use 8 pins as a buss to control two PWM pins. The motors do not run smoothly at slow speed and so I have some reading to do about how others do PWM for motors.
Thanks, I hope it helps you get started. That's the whole purpose of these forums.
The PWM that the BS2 generates is NOT intended for motor control.
If you have ever looked at the PWM on a scope you will see what I mean. I looks like a bunch of random pulses. These pulses "average out" to whatever PWM value you have specified.
But motors don't handle these random pulses, they want a single pulse with a duty cycle of whatever PWM value to have specified.
That's why I specifically made this project so it could be used for motor control. If you look at the output of the SX on a scope you will see a nice pulse of varying duty cycle.
It takes 20 bytes to set all 16 PWM outputs, at 2400 baud that's 240 characters a second. That's 12 times a second. So you can change the PWM values a maximum of 12 times a second.
The project may be able to run at a higher baud rate, but because of the "fudge factor" caused by the interrupt, I didn't want to push it, and risk getting invalid data.
I'm thinking about expanding this project to make each output programmable to be PWM OR Servo control (0.5 to 1.5mSec pulse every 20mSec). That would be sweet...
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video Display Module" Available Now.
www.sxvm.com
"Great people talk about great things, average people talk about average things, small people talk about other people."
·
We didn't spend much time working with the PBASIC PWM function.
Simply wrote a loop with 'HIGH pin', 'PAUSE timehigh', 'LOW pin', and 'PAUSE timelow' after setting the values based on INA when it changed. A student and his father were doing most of the work. We were trying to get two PWM type pulses on two pins of the one stamp, so the timing of the math needed to be pretty good.
The project is on the back of the bench right now and it has not been touched for a couple of weeks. We were aiming at having it ready for the Tanner Electronics Robot Show but did not have it ready. Our home schooling year has ended and I've got some big projects at work right now, so I probably won't look at it again until my 'TODO list' gets down to 'Learn basics of SX'.
I agree with you that it would be great to have Servo control on this application of the SX.
It would also be great to add the output pins to support 'forward' and 'reverse' on the h-bridges.
Russ
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95 http://www.parallax.com/detail.asp?product_id=30012
Product web site: www.sxvm.com
"It's not getting what you want, it's wanting what you've got."
·
Would a mosfet (or like) attached to the output with a cap (in some arrangement) give enough of a buffer inbetween these random pulses to give you motor control?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·
Steve
http://ca.geocities.com/steve.brady@rogers.com/index.html
"Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
The SX should do this just fine (as in Bean's code)-
Bean, what is the easiest way to make this selectable for Servo/motor (like you stated above)? That is something that I would really be interested in. I've already started rough design for a PCB also [noparse];)[/noparse]
Thanks again, I really learn alot from you guys.
Ryan
I have already started a version that allows each port (8 channels) to be configured as PWM·or·Servo lines.
I will post it as soon as I can.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95 http://www.parallax.com/detail.asp?product_id=30012
Product web site: www.sxvm.com
"It's not getting what you want, it's wanting what you've got."
Post Edited (Bean (Hitt Consulting)) : 5/17/2005 6:16:09 PM GMT
Each port (8 channels) must be the same (PWM or Servo), so the options are
16 channels of PWM
8 channels of PWM & 8 channels of Servo
16 channels of Servo control
Any questions please ask.
Gotta love SX/B man....
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95 http://www.parallax.com/detail.asp?product_id=30012
Product web site: www.sxvm.com
"It's not getting what you want, it's wanting what you've got."
·
Ryan
This conversion may take a while since I am just learning the avr instruction set, but when I get it working, you will see it. Thanks again.
Rick
·· What AVR conversion are you referring to?· I didn't see anything in this thread about that.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Rick is referring to a reply I made to a private message he sent me. I had said that I would like to see the code if he gets it working.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95 http://www.parallax.com/detail.asp?product_id=30012
Product web site: www.sxvm.com
"It's not getting what you want, it's wanting what you've got."
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Rick
I'll be surprised if the avr has enough MIPS to do the job. Unless you add some additional hardware. That's the nice thing about the SX is so damn fast...
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95 http://www.parallax.com/detail.asp?product_id=30012
Product web site: www.sxvm.com
"It's not getting what you want, it's wanting what you've got."
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
---
James Newton, Host of SXList.com
james@sxlist.com 1-619-652-0593 fax:1-208-279-8767
SX FAQ / Code / Tutorials / Documentation:
http://www.sxlist.com Pick faster!
Your right, the interruption is quick and evenly spaced (that's why all paths of the ISR code MUST take the same number of cycles).
And the baud rate is adjusted to account for the time spent in the ISR. Tricky...But greatly simplifies the ISR code.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95 http://www.parallax.com/detail.asp?product_id=30012
Product web site: www.sxvm.com
"It's not getting what you want, it's wanting what you've got."
·
·
I am an artist that works in interactive electronic art.· It was interesting to read that others have found the same problem as I have when using the Basic stamp to control an RGB LED matrix.· My application calls for· 72 RGB LED clusters to control their brightness, the level of the R,G, and B LEDS to blend a color, and on top of all of that to chase the first second and third clusters so the there is a slight wavering rotating around the perimeter of the piece.· I saw your work with the SX chip could this be adapted to run a 6X 6 matrix to give me two 36 LED sections.· My current matrix is 9 X 12 but I can still adapt my circuit.· Any thoughts?
·
Thanks for any help you can offer
·
Daniel Nauke
I assume an 8x8 RGB LED matrix has 32 connections ?
When I get my proto boards I will try some experiments.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
Product web site: www.sxvm.com
"What's the difference between ignorance and apathy ?"
"I don't know, and I don't care."
·
Thanks for the speedy answer!· I have several art pieces that will use a backlight effect.· To do this I would like to use 2 sets of 36 RGB LED "clusters"
·I would like to have control of the R, G, B LEDS so that I can blend them to make·various colors, and I would also like to be able to dim and brighten the entire set of LEDS.· The last effect is the one that adds the fun to the task - I would like to have the LEDs kind of quiver.· To do this I thought of chasing them either 123 - 123· - 123 or 1234 - 1234 - 1234 where one cluster would be just a bit brighter as it revolved around the 36 LED clusters.
I built a circuit with a Basic Stamp 40 pin using a 9 x 12 matrix but it does have the blinking problem.· Your work with the SX chip sounds like it could be an answer.· Thanks for the help!
Daniel Nauke
Nauketec@nauke.org
That would make the project possible. Thanks for the info...
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
Product web site: www.sxvm.com
"What's the difference between ignorance and apathy ?"
"I don't know, and I don't care."
·
BTW I just got my SX kit yesterday and I will be coming back for a few questions from time to time.· They will probably be very basic questions as I am way out of my comfort zone with this.
Right now I have to hop on a plane.· I'll be taking Guenther's book with me.
Thanks,
Chris I.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
Product web site: www.sxvm.com
"One experiment is worth a thousand theories"
·
1. Can this chip be addressable so it can be used for more than 16 pwm outputs, say i want 32 or 48 etc.?
2. Could you explain or give an example by pic using led's in a matrix?
3. The other thing that would be nice is the ability to change PWM!
With my research i believe that true RGB is best handled by red, green and blue each having thier own PWM frequency because the color mixing as how the computer does it to how the LED's do it is not linear( if that's the proper word). I have not tried the different PWm for each color but that is my next project.
Is the SX28 fast enough to process audio and turn the pwm outputs off and on? If you could get this chip to do 3 inputs of audio and allow you to choose what outputs you want those to·control you would definately have a great chip. The 3 audio inputs can be processed from filters for low, mid and high audio. Of coarse you would loose some pwm outputs for the audio input. Audio and making the chip addressable would be great.
·I have done alot of research with doing color mixing with led's using pulse width modulation i believe that true RGB is best handled by red, green and blue each having thier own PWM frequency because the color mixing as how the computer does it to how the LED's do it is not linear( if that's the proper word). I have not tried the different PWm for each color but that is my next project. Positioning led's within cubes etc. for proper illumination is also a task. I spent months developing some color cubes using red, green and blue led's and found out a couple of limitations. First if using a computer, the computer generates perfect examples of color but will not generate the same colors to the led's and of coarse you can not develope the color black. It is very important to use the proper wavelengths of red, green and blue led's to get true RGB. In some cases·you can use twice as many led's·to generate a brighter red otherwise your current limiting resistor values·will have to be increased because of green and blue are much brighter.
Kevin
Post Edited (DigitalDj) : 8/9/2005 2:05:22 AM GMT
I saw another post in the sandbox about making an 8x8 and I thought it would be cool to have some fun features for your 16 channel pwm controller.
How about being able to send a 'transition time' to them? Basically the pwm are being used to light led clusters - it would be cool to tell the channel to go from red to blue in so many seconds. Sure the pc or whatever that is talking to the board could do that as well, but I think it could be done smoother on the chipside. (and less things to send to the board - kinda like a 'target' pwm and time to get there. It would also be cool if there was a 'global' channel for the same thing. If all of the channels are on different locations/colors and a global command and transition value is sent, then they would all change from what they are to the target gradually - and independently.
Might be too complex / too many variables. (shrug) I really gotta get into sx/b programming as you are really showing me the potential of whats available on this side of microcontrollers.
The next step will be to make a 8x8 multiplexed PWM program. For a single color LED matrix.
Then a 8x8x3 multiplexed PWM program. For a RGB LED matrix.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
Product web site: www.sxvm.com
"One experiment is worth a thousand theories"
·
Don L.
say - how many LED's do you think we could string on each PWM channel? (or would this just be an 'attach a transistor/resistor/capaciter circuit to increase voltage' type of thing? (my first guess. (Or would we use a fun chip like a ULN2803 to 8 of the PWM lines - which I see as totally do-able.
I understand about the overlay project taking priority - expecially since I want one of those too!
Did you get your sx52 boards yet?
Daniel