PWMout

Hi everyone,

I have a two part question about PWM output for voice control:

Firstly, is there any way to get 2 PWMs outputs from an 18x picaxe?

Secondly, what circuitry would I need to separate the high and low parts of the pwm into two high/low logic outputs, ie; when PWMout is on the high section of pulse, final output is 0,1 and when PWMout is on the low part of the pulse, final output is 1,0.

My question relates to the positional control of voice coil actuators.

Thanks in advance,

Marcus
 

hippy

Ex-Staff (retired)
There is only one PWM for an 18X.

Not sure how you mean regarding separating the high and low of PWM but to generate ...

PWM 0 -> A=0, B=1

PWM 1 -> A=1, B=0

A would be driven directly from PWM, B would be the same but inverted.

It may be worthwhile looking at the PICAXE-X2 range which support two PWM and HPWM which would give automatic generation of Both 'A' and 'B' signals.
 

BeanieBots

Moderator
You need a 28X/1/2 if you want two PWM outputs.

For you differential drive, simply run the PWM through an inverter.
One phase will be the raw PWM, the other will be the inverted signal.
 
Thanks for the advice :)

If I use a 28X1, can I use HPWM to achieve the following?

I am using a separate H-bridge driver to drive the voice coil. If the H-bridge input pins A and B are 0 and 1, the coil moves left. If A,B = 1,0 the coil moves right. Can HPWM on the 28X1 create pwm on two pins, where the 'high' part of the duty cycle gives a high on one pin whilst the low part of the duty cycle gives a high on a second pin? So i get ABABABABABABAB instead of A0A0A0A0A0A0A0?

I currently have _-_-_-_-_- on one pin of the 18X using PWMout
I want - - - - - - on pin A and - - - - - - on pin B (while pin A is high, Pin B is low and visa versa). This way I could control the position of the voice coil actuator. If pins A and B are each high for 50% duty cycle, the actuator will be held central. If the high part of the duty cycle increases and the low part reduces (say to 70% on pin A, 30% on pin B) the actuator should position itself towards one end of its range.

Would this be possible directly out of the 28X1?

Cheers

Marcus
 
Last edited:

eclectic

Moderator
@marcuselec

Not a definitive answer, but, as a possible line of research,

try the following two programs and
look at the results on your 'scope.

Code:
;Manual 2, p70 - 72 ...
; Man 2, p 140 ...


#picaxe 28X1
;Prog 1
; tested on pwm 1  and pwm 2
; physical legs 12 / 13
pwmout 1 , 249, 500 ;f= 4kHz d = 50%

pwmout  2 , 249, 500


stop

#rem
#picaxe 28X1
;Prog 2
; tested on Hpwm A  and Hpwm B
; physical legs 13 / 23

Hpwm 1,0,1, 249, 500

Stop
e
 

hippy

Ex-Staff (retired)
Any of the PICAXE which support HPWM can generate a pair of normal and inverted PWM signals though one might be limited in which of the four outputs can be used in pairs.

I used this to drive a piezo direct though a voice coil will probably require a higher current and thus need a H-Bridge or similar drive, and you seem to have that already ...

http://www.picaxeforum.co.uk/showthread.php?t=11548

One thing not mentioned is how responsive the system has to be and I'm not sure what "voice control" really is.
 
Ok, it looks like the 28X1 is the way to go. How about the 28X2 though? Would this also be capable? I might as well go for the X2 if possible so I can play with the scratchpad etc. I have another project on the go which will require GPS input. It would be great to be able to use the 28X2 throughout so I can get to know it's capabilities - Gotta love playing!

Thanks again for all the advice.
 

eclectic

Moderator
Marcus.
From Manual 2, page 70

Please note that although the 28X1 and 28X2-3V support hpwm, the 28X2 does
not. This is a design restriction of the silicon within the 28X2 chip.
Both 40X2 and 40X2-3V parts support hpwm (40X1 does not).

Please read the whole of the section for context.

e
 

hippy

Ex-Staff (retired)
I might as well go for the X2 if possible so I can play with the scratchpad etc.
The 28X1 supports scratchpad.

It is unfortunate that there isn't a single 'PICAXE standard' where every PICAXE chip has the same capabilities, abilities, and all support the same commands, but this is outside our control. With the future M2's there will be a better convergence though there will be some differences in capabilities and commands supported between parts and it will likely always be so.

The only way to force a 'PICAXE standard' would be to not support anything which isn't available on all parts and, on balance, that would probably be worse than what we have at present.
 
Top