ADC comms

adub

New Member
I was trying to think of a way to do serial comms between two picaxes while still doing pwm on the receiving axe.

Basiclly using a master pic to controll several 08Ms each doing a different pwm output with the main controller telling them each what to do. The problem is that serin disturbs the pwm output.

I thought of an i2c controlled digital pot that could be read by on 08m to make changes to its settings. Each 08m would have to have a digipot set by the master controller and use that setting for its pwm output or other "stuff" for that matter

Any thoughts?
 

Fowkc

Senior Member
From reading the manual, I get the impression that using SERIN will not affect the PWMOUT command:

"This command is different to most other BASIC commands in that the pwmout
runs continuously (in the background) until another pwmout command is sent."

and

"pwmout stops during nap, sleep, or after an end command"

What is the PWM output doing when SERIN is waiting?
 

adub

New Member
hmmm.....I guess I read that wrong. I thought pwm was affected when the timer was in use by serial in. I'll have to go experiment.
a
 

premelec

Senior Member
please note that there are two commands: PWM and PWMOUT - PWMOUT runs continuously PWM does not...
 

hippy

Technical Support
Staff member
PWMOUT once running should execute entirely in hardware so it shouldn't affect SERIN and nor should a SERIN wait affect it - All 'shoulds' because I haven't tried it.

SERVO and other commands are a different matter because they are not hardware-only functions.
 

bwevans

Member
So if you were using other commands, toggling two outputs for ULN2003 stepper control for example (but not important), then which would be quicker to execute: the incoming serial command or a readadc?
 

moxhamj

New Member
servo output does seem to be affected by serin and this uses the same timer - I was testing this last night. Very simple code - serin, then servo output to a servo, then a pause for 1/2 second. During the pause the timer keeps running, and the servo stays solid. But when the serin executes it causes the servo to glitch.
Solution - serin, then a loop executed 10 times with pulsout 1.5 to 2.5ms, then low for 20ms (ie, the standard servo protocol). The whole loop is about 220ms. For some reason, this does not glitch when it goes to the next serin.
I need pwmout to also work so I should be able to answer the question for pwmout soon. Using pulsout in loops might be the answer. Otherwise perhaps analogue comms are an option.

Addit- thinking through this some more, if one has just executed a loop of say 20 pulsouts with known high and low periods, then jump to a serin, the time taken to do the serin should be fairly well known, especially if the data is being sent continuously. So if the output is set low just before the serin, then serin runs for a fixed time, then it should be possible to calculate a high pulse time to match the desired pwm ratio. This one pulse might be a bit longer than the others but the ratio will stay constant.

Edited by - Dr_Acula on 06/01/2007 07:30:15
 

adub

New Member
I have checked. Serin does not affect pwm. I must have been thinking of the servo command.

I do see a use for using ReadADC though. If a master controller wanted to set up a value to be read at leasure(ie. not time critical) for the slave pic then adjusting a digipot that can be read in a loop would still be a usable way to exchange information.

Speed of reading is another issue. If there are time critical actions being performed by the slave axe then reading the adc value instead of pausing for serin might be the best way to go until we get the promised "time out" serin at some future as yet undisclosed time.

Some handshaking would be necessary to keep the slave from having to wait for the master to send data. I have used setint to read serin successfully. With the master just sending data as usual and the interrupt starting with serin and have done so without losing any data. This should also use less memory than doing a bitbanged serial read.

arvin
 
Top