Is this true? A Picaxe08M is awesome, except it will not give me a way to measure the time between interrupts?
Should I upgrade? Which Picaxe do you recommend? I am looking for a minimum pin count.
Don't say Arduino now, ya hear!
And I will strip the main loop of anything I don't need there. It's the unpredictable interrupts that will -ehm- disrupt the accuracy. The good thing i: there is no cumulative error. Every new pulse will be timed against the last. It will give an instantaneous reading of power use.
As for unpredictable interrupts: I will just have to figure if that's a bad thing. And by how much. I will probably hook up my oscilloscope to a toggling output pin to measure the frequency of the main loop.
If you mean there is no access to hardware timer you are right. The settimer command is not available. But couldn't you use a variable and increment it as it loops through main. Initialize it at end of interrupt routine and clear at start of interupt. Of course after retrieving it's value first. This wouldn't be a precise measure of time as you don't know where the interrupt occurs from within main loop and accuracy will be worse depending on length of main loop. Also if there are asynchronous subroutines off of main it will create further variations to the timing. So as they say you cannot make an omelette without breaking eggs you may need another part.
Why don't you dip your toes in the raw pic programming world where you can access the hardware timers on all parts. : )
That stuff scares me. Like opamps scared me a year ago. This projects uses one. So give it time.
The real reason is: I'm done learning on this project. It's been months now and it's time to move on. Or so I hoped.
JALv2 as an option to assembly. It is free and from what I have read PASCALish. It is a high level language and there is a good group of people supporting jallib, which is a group of libraries that can be downloaded and included in a program as opposed to reinventing the wheel all of the time.
I could put a sleep 1 into the main loop that is otherwise almost empty and clean. Calibrate later for the actual time it takes to loop a thousand times. This is my main loop right now, but I think I will move the do/while/loop to the interrupt routine.
main: do while wheel_count >= rev_factor wheel_count = wheel_count - rev_factor kwh = kwh + 2 write addr_kwh, kwh sound pin_bell, (121, 50) loopgoto main
I will give it a go later.
It depends a bit on what intervals we are talking about. Even PICAXE 08M have the count command that gives you pulses inside a timeframe. Like this:Count 1, 5000, w1That gives you the number of pulses on pin 1 in a 5 seconds period. It’s not interrupt triggered but you could make a trigger start the count.
The timing range is from 1ms to 65sec.
Yes, that is the kind of alternative I might need. However, I already wrote my code using interrupts. The interrupts allow me to do some "multi tasking". In my case transmitting the values in memory over a serial line.
Your not saying much about what your building and what is done in the ’multitasking’ area. Is this PICAXE code? Your mentioning transmitting data over serial to what?If you move to a 28X or above you can have it as a i2c slave and your master system could just ask for the value when it needs it.
This is for my electricity meter reading project. My photo transistor look at the wheel in my Energy Company's meter. Every revolution gives one pulse. The filtered/amplified pulse triggers an interrupt in my picaxe. I am using a 28x1 for now.
Every interrupt is 1/187.5th of 1 kWh or .0053 kWh.
The current code is simply counting revolutions until another kWh can be added to the main variable "kwh". But now I would like to measure the time between those pulses as well because that is a measure of current current use.
Both variables (kwh and current) must be transmitted to one of my computers. Preferably on demand. There it will be collected in a database. I want to use RS232 signals for that.
The picaxe 08M has all of that except for the timer to measure the interval. Now I need either a hack or a bigger Picaxe.