ahanktcd, · You are correct. To use higher baud rates the serial reception would have to be in the interrupt routine. · As it is, the interrupt already uses ALOT of the cycles. · If you decreased the interrupt rate (which would lower the PWM update rate) you could probably do it.
[noparse][[/noparse]edit]· · I just looked at the code again. · The PWM or servo outputs only update at 195 Hz (1950 Baud). · So a higher baud rate is not going to make them change any faster.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap 4-digit LED display with driver IC·www.hc4led.com
I hate to bring this thread up again... but I was wondering Bean if you could help me understand the PWM code. I am just begining with SX/B as a matter of fact my Kit is Arriving on Monday and one of the first projects I have set up is a motor controller. I know I can buy one, but I wanted to start from scratch based on the L298.
The ASM code for that program is kinda hairy because of the requirement that the interrupt routine take exactly the same number of cycles each time through. Because it communicates serially. If you are putting ALL the code in the SX (in otherwords the SX that is generating the PWM is also deciding what the PWM should be) then you shouldn't need the serial comms, so you don't have to worry about the cycle counting.
Did you by chance order the SX48 proto boards ? If so you are in luck, because they have 2 16-bit timer counters that have a directly hardware PWM output.
How many channels of PWM do you need ?
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap used 4-digit LED display with driver IC·www.hc4led.com
I am a total beginner with the SX chips..and have no experience with ASM..·and to answer your question I really only need 2 PWM channels for two motors.
My first project is to create a Motor Controller for the Stamp based on the L298 that is controlled with a Serial command.
I did not purchase the SX48 Protoboard... I just got the Lite Version. It came with two SX28 Chips. If I had a way to incorporate the SX48 into my own project that would be great but I don't have the equipment soldering SMD.
I suppose this is off topic, but I downloaded this code and I am going to use it in in a motor controller.· But before it would compile correctly, I had to change the variable "count" to "counter", it was recogising "count" as a command.· Has anyone else had to do this?
Forgive me if this is stupid, I just got my first SX today, I've only worked with the BS2 before.
I know I'm resurrecting an ancient thread, but this is a point of confusion at my lab.
In the code, you specify 21 bytes, "!PWM" + config byte + 16 data bytes. In the quoted example, you only specify 20 bytes. Could you clarify?
Also, does anyone have any suggestions for forcing Python to write ASCII 0x03 into the config byte (I'm using Pyserial's serial.write() method, which only takes a string)? Or could I force it on the SX board by changing
GetSerialChar
PWM_Config=SerialData
to
GetSerialChar
PWM_Config=3
edit: assuming, of course, that I want to control servos.
Second edit: According to my 'scope, it didn't work. I'm getting sawtooth-looking pulses 2.5ms apart.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--
Christopher Agocs
Georgia Institute of Technology
Post Edited (Christopher Agocs) : 8/26/2008 4:35:28 PM GMT
I am building a dual H-bridge motor controller project on a PCB. I have 74 and 116 amp P- and N- channel MOSFETs controlled by NPN transistors. What I need is SX/B code to run an interrupt to accept serial data and operate the NPN transistors to run both full H-Bridges.
I'd like to run somewhere in the 1 to 5kHz range and have control over forward and reverse of both motors while fielding incoming serial data at 19.2kbps or 38.4kbps.
Is there code out there for this or simple PWM code that I can modify to be a full h-bridge controller, all via interrupts?
Comments
· You are correct. To use higher baud rates the serial reception would have to be in the interrupt routine.
· As it is, the interrupt already uses ALOT of the cycles.
· If you decreased the interrupt rate (which would lower the PWM update rate) you could probably do it.
[noparse][[/noparse]edit]·
· I just looked at the code again.
· The PWM or servo outputs only update at 195 Hz (1950 Baud).
· So a higher baud rate is not going to make them change any faster.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
"Remember, you are unique, just like everyone else." Unknown.
Post Edited (Bean (Hitt Consulting)) : 7/18/2006 10:20:49 AM GMT
Any help you can provide would be appreciated.
Mainly the ASM code.
Sailer
The ASM code for that program is kinda hairy because of the requirement that the interrupt routine take exactly the same number of cycles each time through. Because it communicates serially. If you are putting ALL the code in the SX (in otherwords the SX that is generating the PWM is also deciding what the PWM should be) then you shouldn't need the serial comms, so you don't have to worry about the cycle counting.
Did you by chance order the SX48 proto boards ? If so you are in luck, because they have 2 16-bit timer counters that have a directly hardware PWM output.
How many channels of PWM do you need ?
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap used 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
SX-Video Display Modules www.sxvm.com
There are only two guaranteed ways to become weathy.
Spend less than you make.
Make more than you spend.
·
I am a total beginner with the SX chips..and have no experience with ASM..·and to answer your question I really only need 2 PWM channels for two motors.
My first project is to create a Motor Controller for the Stamp based on the L298 that is controlled with a Serial command.
I did not purchase the SX48 Protoboard... I just got the Lite Version. It came with two SX28 Chips. If I had a way to incorporate the SX48 into my own project that would be great but I don't have the equipment soldering SMD.
Thanks,
Eric
I suppose this is off topic, but I downloaded this code and I am going to use it in in a motor controller.· But before it would compile correctly, I had to change the variable "count" to "counter", it was recogising "count" as a command.· Has anyone else had to do this?
Forgive me if this is stupid, I just got my first SX today, I've only worked with the BS2 before.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
NerdMaster
For
Life
So yes, the variable named "count" will have to be changed.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap used 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
SX-Video Display Modules www.sxvm.com
There are only two guaranteed ways to become weathy.
Spend less than you make.
Make more than you spend.
·
You asked me some questions and I responded but you never responded back.. Do you have time to help?
Thanks in Advance,
Eric
I know I'm resurrecting an ancient thread, but this is a point of confusion at my lab.
In the code, you specify 21 bytes, "!PWM" + config byte + 16 data bytes. In the quoted example, you only specify 20 bytes. Could you clarify?
Also, does anyone have any suggestions for forcing Python to write ASCII 0x03 into the config byte (I'm using Pyserial's serial.write() method, which only takes a string)? Or could I force it on the SX board by changing
to
edit: assuming, of course, that I want to control servos.
Second edit: According to my 'scope, it didn't work. I'm getting sawtooth-looking pulses 2.5ms apart.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--
Christopher Agocs
Georgia Institute of Technology
Post Edited (Christopher Agocs) : 8/26/2008 4:35:28 PM GMT
I'd like to run somewhere in the 1 to 5kHz range and have control over forward and reverse of both motors while fielding incoming serial data at 19.2kbps or 38.4kbps.
Is there code out there for this or simple PWM code that I can modify to be a full h-bridge controller, all via interrupts?
Paul