hi all,
Am Sonntag 22 Januar 2006 20:45 schrieb B. Bogart:
Hey all,
[...snip...]
An approach would be to list all the common atributes:
- analog in
- analog out
- digital in
- digital out
- PWM out (maybe?)
based on this we could have three objects:
[analog] [digital] [pwm]
you can drop [pwm] ... it is basically the same as [analog] ..... that the _real_ output is a pwm signal (whose average equals to an analogue dc voltage) is a matter of the used chip .....
Can we simulraneously read and write to any of these devices? (that would be a nice feature)
usually yes .....
You send the message [set 0 0.5< to set the first analog output of the device to half way up its full range. [set 1 1< would set the second analog output to its full range (5v).
Maybe the analog out has modes for say, internal polling, or external polling, and for the range of pins to poll. [poll internal< [poll external<, [range 0 5< polls the first to the 6th outputs)
you mean analogue in, right? at least for the multio, the next firmware will have the option to turn off the auto-update of thechannel(s). polling is alway possible.
The messages we get from the analog object would be something like:
[0 0.5< # first input is 2.5v
So we just need to [route 0 1 2 3 4 5 6] or some more complex method for an unknown dynamic number of inputs.
digital would act the same, except the argument would be a 0/1 rather than a float to turn pins on and off.
right ......
[pwm]
would have only an input, and we set it with [set 0 0.5] to set pwm pin 0 to half way through the PWM range of that micro.
The relative pwm may be a problem, so we could use the hz as the argument to control a servo for example. (where say 1000hz is stop)
you mean output, right? if you need to meassure an incomming pwm signal instead of an anlogue voltage, you just need to make a simple rc lowpass filter (one resistor and one capicator) to get an analogue voltage from a pwm signal.
again: setting or reading a pwm signal with a 50/50 cycle (0.5 in the 0..1 range) is the same as reading an analogue voltage at 50% of Vmax for an analogue input ....
greets,
chris