Precision of picaxe

djsoftlayer

New Member
Hello, whatever takes maximum to the picaxe at 4mhz to execute a command? What would be a maximum time for the common commandos?

It is the function PAUSE precise in small values? , I am executing the command PAUSE 2, and I suspect that the pause is smaller than 2ms, is that possible? Note: I do not have oscilloscope.

With respect to the last question, I am using the following code:

inicio:
If pin7 = 1 Then contar
GoTo inicio
contar:
pause 2
inc xx
If xx >= 250 Then
inc y
Let xx = 0
GoTo calcular
End If
If pin6 = 0 Then contar
If pin6 = 1 Then GoTo calcular
GoTo inicio


As you can see I am counting in steps of 2ms the time that happens when entrance 7 is in high until the 6 are also placed in high (imagines a car that with its wheel touches to a sensor and another one later), the code counts the time that I take to him to arrive from sensor 1 at sensor 2.), of course, the result of the count would have to be a greater time to the real one due to the retardation in the execution of the commandos, but surprising the result is smaller. AID PLEASE!!!!
 

BCJKiwi

Senior Member
How much smaller?

If a few % it may be the 4MHz clock is running a little fast.
The program will be very quick to execute and a small error in the clock will give an error in the result.

xx and y could be set to 1 at the start then xx can be >250, instead of >= (i.e. count from 1 to 250, not 0 to 250)

What is calcular?

What is the maximum count/time?
If xx is a word value max count could be 65335 and y may not be needed.
Is y a word value?
 

manuka

Senior Member
contar = "tell", calcular="compute". Sugerir que usted envíe su solicitud en puro español y vamos a hacer la traducción de Google! (Suggest you post your request in raw Spanish & let us do the Google translation!)

The internal oscillator can be tweaked with OSCTUNE, but it looks as if you are after the execution times as well?
 

moxhamj

New Member
1ms per instruction. Very approximately.

Pause is very accurate, but all the other instructions are adding to the time.

Do a test:

for w0=1 to 10000
b2=5' any instruction to test
next w0
high 1' turn led on

Time how long that takes. Then divide by 10000.

If you want accurate timing have a look at the Pulsin command.
 

westaust55

Moderator
Dr Acula is right in suggesting the PULSIN command for best accuracy for time less than 0.5 seconds.

If you use a 74HC74 (dual D type flip flop with Set and Reset inputs)

Normal/standby condition is both switches open and Set and Resrt pins pulled high with say 4.7KOhm resistors.

Then using one switch to start and pull the Set pin low as vehicle moves over the switch will cause the output Q to go high (change to a 1)

Then when the vehicle moves over the second switch it will pull the Reset pin low and cause the output Q to go low (change back to a 0)

Using PULSIN 6, 1, w5 will check input 6 for a change to a 1 and count the time into word variable w5 until the input changes state to a 0.

Each count in w5 represents 10 microseconds (us) with the PICAXE running at 4MHz.

As a word variable can hold a maximum value of 65535, the maximum timing duration with PICAXE at 4MHz is 0.65535 seconds.

EDIT: As some further comment/information
The pulsin command is used with the SRF05 ultrasonic range finder to measure the time in microseconds for a sound pulse to travel to an object and back. The timing using the PULSIN command for this application is very accurate.
 

Attachments

Last edited:

BCJKiwi

Senior Member
@Manuka
I Figured Calcular was calculate or similar, the point is that there is no calcular in the posted code. The "smaller result" could be a coding issue in calcular but as it was not posted how would we know? - damn, misplaced the crystal ball again!
 

djsoftlayer

New Member
En espanol

Hola, cuanto le lleva máximo al picaxe a 4mhz ejecutar un comando? Cual sería un tiempo máximo para los comandos comunes?
Es la función PAUSE precisa en valores pequeños?, estoy ejecutando el comando PAUSE 2 y sospecho que la pausa es menor a 2 ms, es esto posible? Nota: No tengo osciloscopio.

Respecto a la última pregunta, estoy usando el siguiente código:

inicio:
If pin7 = 1 Then contar
GoTo inicio
contar:
pause 2
inc xx
If xx >= 250 Then
inc y
Let xx = 0
GoTo calcular
End If
If pin6 = 0 Then contar
If pin6 = 1 Then GoTo calcular
GoTo inicio

Como puede verse estoy contando a pasos de 2ms el tiempo que pasa cuando la entrada 7 está en alto hasta que la 6 se coloca en alto también, claro está el resultado de la cuenta debería ser un tiempo mayor al real debido al retardo en la ejecución de los comandos, pero sorprendentemente el resultado es menor. AYUDA PORFAVOR
Imagina un carro que con su rueda toca un sensor y luego otro más, el código cuenta el tiempo que le llevo llegar del sensor 1 al sensor 2.
 

eclectic

Moderator
DJ.

Please post the code for the FULL program.

Por favor, enviar el código para el programa completo.

eclectic
 

djsoftlayer

New Member
Complete Code

symbol z = b0
symbol y = b1
symbol n = b2
symbol xx = b3
symbol ds = b4
symbol clase = b13
symbol claser = b6
symbol cantcar = b7
symbol rojo = 7
symbol amarillo = 6
symbol verde = 5
symbol va = w5
symbol vr = b8
Let z = 0
Let y = 0
Let n = 0
Let xx = 0
Let ds = 109 / 100
Let clase = 0
Let claser = 0
Let cantcar = 10
Let va = 0
'Comprobacion de entradas
inicio: If y >= cantcar Then promedia
'if pin7=1 and pin6=1 then nocar
If pin7 = 0 Then contar
GoTo inicio
'Si no hay carros
nocar: pause 10
inc n
If n >= 250 Then
inc y
Let va = va + 120
Let n = 0
'debug y
End If
GoTo inicio
'Si se interrumpe el primer sensor
contar: pause 2
inc xx
n = 0
If xx >= 250 Then
inc y
Let xx = 0
GoTo calcular
End If
If pin6 = 1 Then contar
GoTo calcular
'Calculo de velocidad o determinacion de obstruccion
calcular: 'if xx=0 then
'pause 10
'inc z
'if z=>200 then
' inc y
' let z=0
' goto inicio
'end if
' goto inicio
'end if
Let z = 0
let vr=1042*ds/xx MAX 120
debug vr
pause 1500
Let va = va + vr
inc y
Let xx = 0
GoTo inicio
'Promedio de la velocidad
promedia: Let va = va / cantcar
If va <= 20 Then
Let clase = 0
End If
If va > 20 And va <= 40 Then
Let clase = 1
End If
If va > 40 And va <= 60 Then
Let clase = 2
End If
If va > 60 And va <= 80 Then
Let clase = 3
End If
If va > 80 And va <= 100 Then
Let clase = 4
End If
If va > 100 Then
Let clase = 5
End If
Let y = 0
debug clase
Let va = 0
If clase <> claser Then
claser = clase
End If
GoTo inicio
 

Dippy

Moderator
With all that other code affecting the total delay Pause would have to be miles out to suggest that your total loop <2mS.

How have you come to your conclusions about the pause time?
i.e. How have you measured it?

What PICAXE are you using?
What is the response time of your sensors?
And what are your sensors?
 

djsoftlayer

New Member
Pic

Picaxe 18X
Pression sensor, a simple suich that a wheel can press

As you can see I am counting in steps of 2ms the time that happens when entrance 7 is in high until the 6 are also placed in high (imagines a car that with its wheel touches to a sensor and another one later), the code counts the time that I take to him to arrive from sensor 1 at sensor 2.), of course, the result of the count would have to be a greater time to the real one due to the retardation in the execution of the commandos, but surprising the result is smaller.
 

djsoftlayer

New Member
Picaxe 18X

Picaxe 18X
Pression sensor, a simple suich that a wheel can press

As you can see I am counting in steps of 2ms the time that happens when entrance 7 is in high until the 6 are also placed in high (imagines a car that with its wheel touches to a sensor and another one later), the code counts the time that I take to him to arrive from sensor 1 at sensor 2.), of course, the result of the count would have to be a greater time to the real one due to the retardation in the execution of the commandos, but surprising the result is smaller.
 

eclectic

Moderator
DJ

Dippy said
"How have you come to your conclusions about the pause time?
i.e. How have you measured it?

What PICAXE are you using?
What is the response time of your sensors?
And what are your sensors?"


What instrument do you use to measure the time delay?

Please read Manual number 3. Pages 25 and 26


¿Qué instrumento que utiliza para medir el tiempo de retraso?

Por favor, lea Manual número 3. Páginas 25 y 26
 

BCJKiwi

Senior Member
Well I'll ask again some of the questions not yet answered;

How much smaller?

What is the maximum count/time?
If xx is a word value max count could be 65335 and y may not be needed.

Count appears to take place in xx and y

If the count is greater than 256 in y then it will roll over and start again giving a false low value - so, again, how long is the count??
 
Last edited:

sedeap

Senior Member
Translating spanish-english-spanish

Well I'll ask again som eof the questions not yet answered;- damn, misplaced the crystal ball again!

How much smaller?

What is the maximum count/time?
If xx is a word value max count could be 65335 and y may not be needed.

Count appears to take place in xx and y

If the count is greater than 256 in y then it will roll over and start again giving a false low value - so, again, how long is the count??
Well BCJKiwi I envy you Crystal ball... (can you clone it and send me one?) LOL...

As i understand, this fella want to make one time-lapse counter for a model race car or autoslot (Like Scalextric) and read the result, so he count the lapse and if is great than 250 inc "y" .

The timelapse must be small, so, because he ask about accuracy in pause command.

Take a look at this video and you maybe find why i say "small timelapse" CarSlot

Now for this fella...djsoftlayer

>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*

Cuando BJCKiwi consulta acerca de cuanto tiempo quieres medir y que tipo de Picaxe utilizas, es para saber como ayudarte, ya que no siempre se puede adivinar usando una "bola de Cristal" lo que intentas hacer.
Yo entiendo que lo que quieres lograr es un timer electronico para calcular el tiempo de las vueltas buscando dar la mayor velocidad a tu auto.
¿Cómo sabes que el resultado es menor que el que deberia medir... usas un ampolla de reloj cronometro como en las olimpiadas? o ¿buscaste una mejor solucion?
¿Cuanto es el desfasaje entre lo que deberia ser y lo que es? ¿son milisegundos, segundos o minutos?
Si el valor de "Y" supera los 255, se vuelve a cero, por lo que la lectura puede ser erronea y menor de lo esperado.
una solucion puede ser el de hacer una interfase entre un cronometro de ampolla y controlarlo con un picaxe para evitar que los sensores de presion emitan doble impulso (al tocar el eje trasero del auto de nuevo el sensor) que pueda hacer que se reinicie la cuenta, dando errores de conteo y lecturas.

Cualquier otra consulta especifica que tengas en español, la puedes hacer el el thread que inicie especificamente para los que quieran consultar de esa manera AQUI , el cual es regularmente controlado por quienes hablamos en español ( y quienes no, como Dr_Acula, Dippy, Hippy y otros genios de los MC...LOL) que es mas apropiado y mas seguro de obtener respuestas en tu idioma, evitando hacer traducciones con google y babelfish, que no siempre dan los resultados esperados, eso lleva a perdidas de tiempo y malos entendidos.

Salu2
 
Top