PWM and stuff
scony
Posts: 14
Howdy,
I am building a quadcopter as my masters thesis. The goal of thesis is to compare few different platforms as core of quadcopter. For now I've choosen arduino and raspberry PI. I need third one, so I found parallax propeller. I'm very excited about 8 cores(cogs). However I am still not convinced should I buy it.
First of all, I would like to ask simple question for thoose who have propeller in home.
Say this is my code:
The second question is, can I generate PWM using some more complex approach ?
My goal generally is to produce PWM of at least 200Hz frequency with resolution of 1000 points, so I can set exactly say 49.9% duty cycle.
I am building a quadcopter as my masters thesis. The goal of thesis is to compare few different platforms as core of quadcopter. For now I've choosen arduino and raspberry PI. I need third one, so I found parallax propeller. I'm very excited about 8 cores(cogs). However I am still not convinced should I buy it.
First of all, I would like to ask simple question for thoose who have propeller in home.
Say this is my code:
void xxx() { while(1) { high(26); //high or low, generally change of pin state } } int main() { cog_run(&xxx, 10); }My question is, how many times per second will the line:
high(26); //high or low, generally change of pin statebe executed ? I am asking, because I am curious how frequent and what resolution PWM can I generate just like that.
The second question is, can I generate PWM using some more complex approach ?
My goal generally is to produce PWM of at least 200Hz frequency with resolution of 1000 points, so I can set exactly say 49.9% duty cycle.
Comments
Weight is another factor.
This is a good example, and shows where different 'cores' may have issues. (strengths/weakness)
How many of these PWM channels do you need ?
A single Prop COG can run at 20MOPs, and a software point rate of 200,000/s is what your spec calls for.
You can 'fit' up to 100 opcodes into that 5us
Browse the OBEX for PWM examples of various PWM approaches,with varying numbers of channels..
Btw. Thanks ! This whole 'obex' seems legit. I see I ll probably need to use counters, so I can achieve better resolution.
There are only 2 counters per COG, and they do not naturally do Low Frequency PWM (classic 2 edge per period) - they do however have a high frequency PWM mode, suited to RC DAC use.
Software PWM can meet your resolution specs, quite easily, and with a little care, I think the SW-PWM could manage 1/25000 classic PWM ( 14.6 bits precision) on up to 18 pins (or 9 or 32) , using two cogs. (5ms period)
One COG runs WAITCNT and pin updates 'flat-out' and the other COG converts the user PWM value to an array of WAITCNT : PinValues deltas + any other stuff at the 5ms rate.
https://docs.google.com/document/d/1f4YFx_B5asn-ARQCsG16yNJoPDlvuH6ok6ZRIu_F5U4/pub#h.5ztoqjcun1ve
Yeah right. I've been looking for solution for 1 cog that scales up, but I forgot, due to multicore environment I can make some co-op approach like you did.
Well, thank you all. I am convinced now. I'lll order Propeller tomorrow.
either from parallax or other sources.
They come in different sizes and with different IO capability. Servo headers, small motor drivers etc. some with ADC ... SD-Card ...
IIRC the flight code runs @ 250Hz.
Thanks, I'll check this out. Anyway, I'll port my arduino's C code.