1-5us pulse capture

boriz

Senior Member
You seem to have edited your post. You said you were using a 0.1uF capacitor. Now it's ten times larger!

The time constant (TC) for 1uF * 10K = 0.01 Seconds (10mS). The time it takes to charge (or discharge) a capacitor by 85% is about 2 time constants (2TC). So it will take about 20mS to discharge that capacitor from 5v to <1v. Far too long. You are aiming for 2TC of about 500uS (about 1/40th of your current figure). Also, it will be hard to charge such a large capacitor in 1uS, so your 'weak' port might not be charging the cap enough.

Remember: TC (in Seconds) = C (in Farads) * R (In ohms)
You want a 2TC of around 500uS (0.0005 Seconds) for discharging.
You want a 2TC of about 1uS (0.000001 Seconds) for charging.
Also bear in mind that the discharge resistor is effectively the lower leg of a divider, the upper leg being the output resistance of your port, so don't make it too small.

EG: A 22nF capacitor * 10k resistor has a 2TC of about 440uS and as long as your port has an output impedance of less than 25R, then it will have a charging 2TC of 1uS or less. (2uS for 50R, 4uS for 100R etc).

Measure the output resistance, calculate the required capacitor, then the discharge resistor. Use a signal diode (not a rectifier diode). As far as I know, any capacitor type should be ok, as long as it's on spec.
 

Mad Professor

Senior Member
boriz: Thanks for that info, I will try and see what I can find out.

I got my new 28X2 in the post this morning, along with a 4Mhz, 8Mhz and 16Mhz Resonators.

This will be my 1st time of using the new X2 range of picaxe chips.

As for overclocking the 28X2 do I just have to connect up the Resonator or do I also have to run a command?


This is the code I am using with the 28X2, seems to be working the same as the 18X.
Code:
#picaxe 28x2

let dirsB = %11111111
let adcsetup = 0

let pinsB = %00000000

Main:
if pinC.0 = 0 then goto no_step
if pinC.0 = 1 and pinC.2 = 0 and pinC.1 = 1 then goto Step_CW
if pinC.0 = 1 and pinC.2 = 1 and pinC.1 = 1 then goto Step_CCW
goto main

no_step:
let pinsB = %00000000
goto main

step_CW:
let b1 = b1 + 1
goto step2

step_CCW:
let b1 = b1 - 1
goto step2

step2:
let b1 = b1 & %00000111
Read b1,b2
Eeprom 0, (%00000001,%00000011,%00000010,%00000110,%00000100,%00001100,%00001000,%00001001)
let pinsB = b2
goto main
But I noted somthing with the code this morning.
If the step pin is high the code will keep looping and make the motor step.

I need to add somthing to the code so once the step pin has gone high, and the motor has moved one step, it will not move again unto the step pin and gone low and then high again.
 

eclectic

Moderator
@MadProf.

For the frequency control,
see SETFREQ, manual 2, page 183.

If you own the 5 volt 28X2,
then you can only go to 40MHz,

so you'll also need a 10MHz resonator.

e
 

Mad Professor

Senior Member
Ok thanks, I will order a 10Mhz ASAP, but for now I will just overclock it to 8Mhz.

As for my question about how to make the program wait unto the step pin go's low again I changed my code.

From:
Code:
step2:
let b1 = b1 & %00000111
Read b1,b2
Eeprom 0, (%00000001,%00000011,%00000010,%00000110,%00000100,%00001100,%00001000,%00001001)
let pinsB = b2
goto main

To:
Code:
step2:
let b1 = b1 & %00000111
Read b1,b2
Eeprom 0, (%00000001,%00000011,%00000010,%00000110,%00000100,%00001100,%00001000,%00001001)
let pinsB = b2
do
if pinC.1 = 0 then goto main
loop
Is this the right way about doing it, I have bench tested the change and it seems to work ok.
 

Mad Professor

Senior Member
I am just using the internal resonator and using the setfreq m8 command, to overclock.
But just re-read the manual for setfreq and the 28X2 runs are 8Mhz anyways, Doh!

Once I am sure it is working ok, I will then play with the external resonators and overclock it more.
 
Last edited:

Mad Professor

Senior Member
It's been awile since my last post.

My wife and I had some bad news so we have been dealing with that.

I have been testing with the 28x2 now running at 40mhz, and even at this speed the 28x2 is not able to cope.

I can get it close to the running speeds I am looking for, but the picaxe is not able to make each step smoothly.
I now have to go back to the drawing board.

Thanks again for eveyones time and help.

Best Regards.
 
Top