PDA

View Full Version : DT-int and SPWM



Macgman2000
- 20th October 2011, 13:55
Hello All,

So I have abandoned using asm interrupts in PBP on 16F1827 and I am now looking at Darrel's interrupts. In particular I want to generate and update 4 pwm channels. These channels are connected to 4 hobby servo's that need to start moving at the same time (sync start) but whose timing (pulse width changes 1 ~ 2ms). The refresh rate is 50 Hz or 16 ~ 20ms.

Has anyone used Darrel's SPWM for this application? Any help would be appreciated.

Best Regards,
Nick

cncmachineguy
- 20th October 2011, 15:13
Hi Nick, Just to be clear, Do you mean you can't have the servo pulse sent to each sevro in series as happens with a regular R/C Rx? I assume if the answer is no you can't, I am sure you have a valid reason not to be able to have the possible 2mS lag from 1 to the next. I will tell you it is the easier way to handle this.

A pointer for you - In the other thread I see you were using the interrupt to control when to update the servo. So I assume it fired every 16-20mS or so. May I suggest you set that up as a 1mS timer. Then increment a counter in the ISR and leave. In your main, check if the timer = 16 (or whatever your frame rate need to be) then update the servos.

ScaleRobotics
- 20th October 2011, 15:21
This won't help you if they all need to have the same sync start, but you might be interested in this. A while back I did wrote code for a PIC12F683 servo pass through device. It used DT_INTS, but not his SPWM. Most of the code for the servo's is in asm, to make it respond faster. It listened for the receiver pulses, times them, and then sends them out to the servo's, allowing you to adjust them with input from say, gyro's, or whatever type of input you want.

http://www.scalerobotics.com/71-pwm-passthrough.html

Macgman2000
- 20th October 2011, 19:39
Thanks guys for your responses. I want to be able to update the servo positions all at once. I am using the servo's in continuous rotation and need to minimize lag between issuing commands to the modified servos. The platform vehicle I am working on needs to have synchronized motion of all 4 servos attached to wheels.

A colleague suggested to use a PICAXE which has a SERVO command that allows up to 8 servo's at once. The output pulses to all the servo's start at once (obviously some pulses will be shorter than others depending on position 1 ~ 2ms). There has to be a way that I can do it on a PIC without assembly.....the scope of this project is too big to spend all my time on assembly code.