Hi. I used portd=portd and 0b11110011 instead of set portd.0 on:set portd.1 on:set portd.2 off:set portd.3 off
but it doesn't work. Flash hex works.
You can see the commented out code that worked.
Trying to set port in one go instead of setting bits.
can a port be set like this?
if I can use portd=portd and var I could just rotate var left / right instead of case.
edit portd=portd and 0b00111111 would not set the bits to change
I got to change a nibble?
Last edit: stan cartwright 2020-06-17
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Most ports have several registers, the generic names in GCBASIC being Port, LAT, and TRIS.
This is to prevent the "Read, Modify, Write" issue (Look it up - too complex to explain here) so whilst PortD = PortD AND 0b11110011 may have worked in ASM on eralyer AVR or PIC devices it is no longer supported by the hardware or the compiler.
Writing to PortD will actually write to LatD so your statement translates to:
LatD = PortD and 0b11110011
if any of the Port pins are pulled lower than 2.5V at the time of reading PortB then that bit in LatB will be set to Zero.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks. I'll leave the code as is.
Setting bits works ok but thought it looked inefficient.
I could not find how to set a port in help so should have guessed it was not possible and anyway you can not rotate 4 bits.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Stan. Of course you can rotate four bits within a byte - but, it the key reading the byte variable/register, mask the bits you are not interested in, rotate and merge back. It may take more code to do this than a direct write (based on a case etc.).
But, it is doable.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
@Stan... before you ask - working code. It is full of serial debug for you. This will not be perfect but is shows how to mask etc.
dimDeviceIDasbytedimDeviceIDMaskasbytedo'Initial value - my assumption is that 0b11----11 where the 1 should not chang we rotate in the -'sDeviceID=0b11000111'this is same as DeviceID.2 = 1HSerPrintCRLFHSerPrint"BitWise Rotate"HSerPrintCRLFwait100msDo'reset rotatation maskIfDeviceIDMask.6=1thenDeviceID=(DeviceID&0b11000011)or0b00000100HSerPrintCRLF2endifHSerPrintCRLFHSerPrintByteToBin(DeviceID)DeviceIDMask=DeviceID&60'same as 0b00111100SetCoffRotateDeviceIDMaskLeftDeviceID=(DeviceID&0b11000011)orDeviceIDMaskLooploop
Enjoy
Last edit: Anobium 2020-06-18
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks.. but if I can't set a port in one command then I would still be setting bits.
I think you could do it in picaxe.Probably thinking of when I used that.
Here is a problem with using and.
The interrupt is every 1ms and the sub increments a counter and when it gets to 20 resets and calls servo, which works
but the if millis and 1 = 0 then motors which I am using to test if millis is an even number ie 0,2,4,6,8,10 to 20 ie every 2ms
but motors does not get called.
millis++ will throw an error if millis and 1 = 0 then motors ;every 2ms not sure what this does or what the intent is
calling motors which may be a long running sub during the interrupt is bad practice. As the interrupt is now blocked. servo will be called every interrupt.
So, not sure this code does anything meaningful. But, change to set flags in your main code to call motors and potentially servo.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anobium and Chris. The interrpt is from gcb demos, 1ms. timer 0 match.
Anobium, I have the robot working with Chris Roper's millis BUT Chris has given me a modified version to test and is now working but Chris is a perfectionist and doesn't want it discussed until tested and finalised.
So I am trying to do the same with 1 interrupt.
the interruppt is every 1ms.
the motors sub I set a port bit on at the start of the sub and turned the port bit off at the end and scoped the port bit and measured the pulse width. It hovered around 8us.
the servo sub is just pulseout 220ms maximum.
Anobium,
"if millis and 1 = 0 then motors ;every 2ms not sure what this does or what the intent is"
It was to test if bit 0 of millis was 0 or 1.
If it was 0 then it is an even number ie 2,4,6...18,20 ms...millis increases by 1 every 1ms.
so every even number call motors
when millis gets to 20 it would call motors as it's an even number and reset to 0 and call servo after 20 1ms interrupts ie 20ms.
Anyway I got it to work by using an every 2ms interrupt and changing the isr sub.
so the motors not working previously must be if millis and 1 = 0 then motors.
I feel chuffed I got it working. Chris, it works the same as using your millis.h but I cannot post code
using that so "re-invented"your wheel :)
The robot uses a V53L0X rangefinder and I tweaked the obtacle avoidance code from old code and added a last_turn variable.
subisr ,every2msmotorsmills=mills+2ifmills=20thenmills=0 : servo;every 10 x 2 msendsub
Last edit: stan cartwright 2020-06-19
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have no objection to you posting or discussing the millis() function or code that uses it.
I was only asking that you don't publish code using the experimental DoEvery Statement.
I appreciate you beta testing it for me but, as I am still testing and optimising memory use on a range of devices so the syntax and use of DoEvery may change before I publish.
To show examples now may indirectly lock uys into a restrictive version in the future.
Last edit: Chris Roper 2020-06-19
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Chris , I worked out my own doevery equivelant so I could post the code for the robot.
It is interchangeable, just comment out your doevery and use the interrupt or comment out the interrupt and use doevery.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anobium, please explain pulseout 2200 us.
It's software so the program stops for at least 2200us...yes?
So if I use an every 20ms interrupt no problem...yes?
If I also calling another event every 2ms ie within the pulseout 2200us what happens to the program flow.
It doesn't "seem" to be causing a problem.
Chris, this applies to using your code to.
Cheers stan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You can use every 20ms but ensure your interrupt does not use Wait as this will mess this up.
As Pulseout and therefore WAIT counts clock cycles (based on frequency) an interrupt of X cycles will impact PulseOut. The total number of clock cycles will be ( PulseOut cycles + X cycles in the interrupt ).
You will get 20 ms 'worth' of PulseOut clock transitions. So, this may be way is it working.
Last edit: Anobium 2020-06-19
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here's the program code. You can see it's working in the youtube video.
You can also see Chris Roper's millis doevery commented out. It looks promising doesn't it?
Chris has lost sleep working on this.
I was up until 2.30am thinking what would I do if I was the robot and an obstacle appeared...and coding the thoughts :)
Please check the motors sub. It looks a lot but take around 8us to execute....no way..
but I only got a Hantek 6022BE.
Just got a £8 salae clone logic analyser, as someone on the forum suggested from ebay. may be more accurate.
Ok if I post as a project with reference to Chris's millis removed?
;fullwave stepper V53L0X robot
#chipmega328p,16
#optionExplicit'#include "millis.h"dirportc.0out;servodirportd.0out:dirportd.1out:dirportd.2out:dirportd.3outdirportd.4out:dirportd.5out:dirportd.6out:dirportd.7out;set up V53L0X
#defineHI2C_DATAPORTC.5;sda portc.4 for nano portc.5 for uno
#defineHI2C_CLOCKPORTC.4;scl portc.5 for nano portc.4 for uno
#defineHI2C_BAUD_RATE400HI2CModeMaster;;v53l0x software restartHI2CStartHI2CSend(0x52)HI2CSend(0x89)HI2CSend(0x01)HI2CStopwait200ms;diml_mot_pos,r_mot_posasbytediml_mot_dir,r_mot_dirasbytedimservoposasWorddimservodir,distance_lo,distance_hi,mindist,last_turnasByte;
#definedistancedistance_hi*256+distance_lo;v53l0x distance
#defineforward1;|
#definereverse255;|--motor direction
#definestop0;|
#defineservopinportc.0
#definewasleft1
#definewasright0;last_turn=randomand1;0 or 1servopos=1500;1.5ms servo mid positionservodir=1;servo rotation directionmindist=200;minimum distance before avoidingl_mot_pos=1:r_mot_pos=1l_mot_dir=forward:r_mot_dir=forward;;set up interruptsdimmillsasbyte : mills=0OnInterruptTimer0Match1CallisrDimOCR0ASbytealiasOCR0ADimTCCR0ASbytealiasTCCR0BWGM01=1; OCR0 = 249 ;1ms; TCCR0 = 0x28; TCCR0 = TCCR0 or 0x03OCR0=124;2msTCCR0=0x28TCCR0=TCCR0or0x04'#define DoEvery0 2, motors ;step motors every 2ms'#define DoEvery1 20, servo ; pulseout portc.0,servopos us ;50Hz servo 'refresh'StartDoTimers;do;main program;check for objects and avoidgetdistance;any object too close?ifdistance<>20then;20 means out of range so skip distance test;distance to obstacle testifservopos>1300then;not pointing rightifservopos<1700then;not pointing leftmindist=200;pointing forward min distanceendifelsemindist=250; left and right min distanceendif;ifdistance<mindistthen;object closel_mot_dir=stop:r_mot_dir=stop;stop motors;ifservopos>1700thenturnright_until_clear;object leftlast_turn=wasrightelseifservopos<1300thenturnleft_until_clear;object rightlast_turn=wasleftelse;obstacle forwardiflast_turn=wasrightthen;turn right againturnright_until_clearelse;turn left againturnleft_until_clearendifendifl_mot_dir=forward:r_mot_dir=forward;go forwardendifendif;;rotate servo left-rightifservodir=1thenservopos=servopos+80ifservopos=2220thenservodir=0endifelseservopos=servopos-80ifservopos=780thenservodir=1endifendifwait30msloop;end of main;-----------------------------------------subisrmotorsmills=mills+2ifmills=20thenmills=0 : servoendsub;-------------------------subgetdistanceHI2CStart;Sys V53L0X Range StartHI2CSend(0x52)HI2CSend(0x00)HI2CSend(0x01)HI2CStopHI2CStart;read distanceHI2CSend(0x52)HI2CSend(0x1e)HI2CReStartHI2CSend(0x53);set the read flagHI2CReceive(distance_hi)HI2CReceive(distance_lo, NACK);read one byte and concludeHI2CStopendsub;-----------------------subturnleft_until_cleardol_mot_dir=reverse:r_mot_dir=forward;rotate anti clockwisewait20msl_mot_dir=stop:r_mot_dir=stopgetdistanceloopuntildistance>mindist;rotate left until clearendsub;-----------------------subturnright_until_cleardol_mot_dir=forward:r_mot_dir=reverse;rotate clockwisewait20msl_mot_dir=stop:r_mot_dir=stopgetdistanceloopuntildistance>mindist;rotate right until clearendsub;-----------------------submotors;left motorifl_mot_dir=stopthensetportd.0off:setportd.1off:setportd.2off:setportd.3offelseifl_mot_dir=forwardthenl_mot_pos++ifl_mot_pos=5thenl_mot_pos=1endifelsel_mot_pos---ifl_mot_pos=0thenl_mot_pos=4endifendif;selectcasel_mot_poscase4setportd.0on:setportd.1on:setportd.2off:setportd.3offcase3setportd.0off:setportd.1on:setportd.2on:setportd.3offcase2setportd.0off:setportd.1off:setportd.2on:setportd.3oncase1setportd.0on:setportd.1off:setportd.2off:setportd.3onendselect;;right motorifr_mot_dir=stopthensetportd.4off:setportd.5off:setportd.6off:setportd.7offelseifr_mot_dir=forwardthenr_mot_pos++ifr_mot_pos=5thenr_mot_pos=1endifelser_mot_pos---ifr_mot_pos=0thenr_mot_pos=4endifendif;selectcaser_mot_poscase4setportd.4on:setportd.5off:setportd.6off:setportd.7oncase3setportd.4off:setportd.5off:setportd.6on:setportd.7oncase2setportd.4off:setportd.5on:setportd.6on:setportd.7offcase1setportd.4on:setportd.5on:setportd.6off:setportd.7offendselectendsub;----------------------------subservopulseoutservopin,servoposusendsub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The idea that
sub isr
motors
mills = mills + 2
if mills = 20 then mills = 0 : servo
end sub
works was inspired by Chris Ropers's doevery a la amstrad basic I suggested to him.
I can see how he is doing it but not from his code which I find difficult to understand.
The sub isr could have various counters to different timed subs....groovy
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
What is needed here is the second User Interrupt function in the Do suite that I have been working on:
Set Pin On
DoAfter 20 Set Pin Off
Would perform the same function as
Pulseout (Pin, 20 ms)
But it would not use the Wait command and be 100% compatible with other interrupts as it is itself an interrupt.
BUT, that is part of the Library I am working on so is not yet ready for testing, hang in there Stan, the more I understand of your needs the more I can refine my thinking.
I will give it priority and try and get you some test code in the next couple of days.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Chris , you are making me feel guilty.
I have a hardware solution if I want from Mr Kent..very complicated but nice offered.
I don't get using wait..the interrupt still works.
That's how I use the robot- r_mot_left=forward : wait 200ms and the motors still turn.
Set Pin On
DoAfter 20 Set Pin Off
Would perform the same function as
Pulseout (Pin, 20 ms)
But it would not use the Wait command and be 100% compatible with other interrupts as it is itself an interrupt.
It's pulseout pin,2ms and would be variable from 500 us to 2500 us. 1500us centres a servo.
I think to simulate pulseout would need a every 10us interrupt.
I've used a servo interrupt before and a stepper motor interrupt before but not together
off 1 interrupt before. smug
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Chris, I don't know why a servo needs pulseing it's position every 20msjust what I found researching.
I think it's for like if the servo is under strain eg a model plane's rudder driven by a servo and the wind resistance.
In my robot code the servo is not under stress so I removed the call to servo in the every 2ms isr
and pasted the contents of the servo sub at the end off the only code that controls the servo and
it is all working fine as before. The every 2ms interrupt is still needed for the motors to perform at peak speed and torque.
;rotate servo left-rightifservodir=1thenservopos=servopos+80ifservopos=2220thenservodir=0endifelseservopos=servopos-80ifservopos=780thenservodir=1endifendifpulseoutservopin,servoposus;this WAS interrupt driven every 20mswait30ms'to allow servo to move slower and not overheat and getdistance to work
Hope your millis is working to plan.
would doafter be
get millis store as mil1
do event
is after=millis-mil1
checked in an interrupt often
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Millis() is working fine and it has been working and included in GCBASIC for a few years now.
Millis() Uses Timer0 and a Long Variable to count the number of milliseconds since a device reset.
You were looking for an easy way to have user based timer interrupts, but as Timer0 was already used by the Millis any code that tried to use Timer0 would disrupt Millis.
What I have been working on is a way to share Timer0 between the existing Millis() function and the new requirement for a user based timer interrupt. As "millis.h" already has all of the code to set up Timer0 on all of the supported devices I used that initialisation code as the basis of the new user interrupts.
The new system is NOT using the millis() function nor does it alter the millis() function in any way you, and anybody else, can continue to use millis() in their code exactly as they always have. The Modified millis.h that I sent you just give an extra hook into the interrupt to allow DoEvery and millis() to coexist without conflicting over timer0.
The help and the example libraries along with any Arduino Documentation contain info on the use of millis().
The new functions are taking time because they have to be designed to work on many different devices and minimise the amount or RAM use, that takes time to design, test and rework the retest for several devices. They are NOT based on Millis() they are independent Methods.
The original Beta code I sent you was specific to your need - the resultant library will be generic.
So the bottom line is that I am NOT working on or with millis - this is a totally separate project to millis but will coexist with millis so that they can share Timer0.
So please USE millis(), do NOT try to create your own millis() function, millis() works now, it has worked for a few years and it has been extensively tested on hundreds of different devices.
DO NOT reinvent the wheel - the DoEvent Library, for want of a better name, is what I am working on, NOT millis() and as the wise man said “if it ain't broke, don't fix it”.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Chris-It's just a hobby. I can wait for for your ideas to be published.
More I experiment,more I learn. So... sorry. I will keep on experimenting with interrupt driven events for my own interests on a 328p or a 18f25k22, all I use.
Your doevery will be useful for making interrupts easier.
Hope the project works out.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi. I used portd=portd and 0b11110011 instead of set portd.0 on:set portd.1 on:set portd.2 off:set portd.3 off
but it doesn't work. Flash hex works.
You can see the commented out code that worked.
Trying to set port in one go instead of setting bits.
can a port be set like this?
if I can use portd=portd and var I could just rotate var left / right instead of case.
edit portd=portd and 0b00111111 would not set the bits to change
I got to change a nibble?
Last edit: stan cartwright 2020-06-17
Most ports have several registers, the generic names in GCBASIC being Port, LAT, and TRIS.
This is to prevent the "Read, Modify, Write" issue (Look it up - too complex to explain here) so whilst PortD = PortD AND 0b11110011 may have worked in ASM on eralyer AVR or PIC devices it is no longer supported by the hardware or the compiler.
Writing to PortD will actually write to LatD so your statement translates to:
LatD = PortD and 0b11110011
if any of the Port pins are pulled lower than 2.5V at the time of reading PortB then that bit in LatB will be set to Zero.
Thanks. I'll leave the code as is.
Setting bits works ok but thought it looked inefficient.
I could not find how to set a port in help so should have guessed it was not possible and anyway you can not rotate 4 bits.
Stan. Of course you can rotate four bits within a byte - but, it the key reading the byte variable/register, mask the bits you are not interested in, rotate and merge back. It may take more code to do this than a direct write (based on a case etc.).
But, it is doable.
@Stan... before you ask - working code. It is full of serial debug for you. This will not be perfect but is shows how to mask etc.
Enjoy
Last edit: Anobium 2020-06-18
Thanks.. but if I can't set a port in one command then I would still be setting bits.
I think you could do it in picaxe.Probably thinking of when I used that.
Here is a problem with using and.
The interrupt is every 1ms and the sub increments a counter and when it gets to 20 resets and calls servo, which works
but the if millis and 1 = 0 then motors which I am using to test if millis is an even number ie 0,2,4,6,8,10 to 20 ie every 2ms
but motors does not get called.
Stan ... the code is not real code. is it?
millis++
will throw an errorif millis and 1 = 0 then motors ;every 2ms
not sure what this does or what the intent iscalling
motors
which may be a long running sub during the interrupt is bad practice. As the interrupt is now blocked.servo
will be called every interrupt.So, not sure this code does anything meaningful. But, change to set flags in your main code to call
motors
and potentiallyservo
.Why are you reinvrenting the wheel and not using the millis.h library?
@Chris... that explains things... I assumed that Stan was using millis library.... hence, I was getting the error during
millis++
The ISR wil fail the way is it structured. So, a rethink is required.
:-)
Anobium and Chris. The interrpt is from gcb demos, 1ms. timer 0 match.
Anobium, I have the robot working with Chris Roper's millis BUT Chris has given me a modified version to test and is now working but Chris is a perfectionist and doesn't want it discussed until tested and finalised.
So I am trying to do the same with 1 interrupt.
the interruppt is every 1ms.
the motors sub I set a port bit on at the start of the sub and turned the port bit off at the end and scoped the port bit and measured the pulse width. It hovered around 8us.
the servo sub is just pulseout 220ms maximum.
Anobium,
"if millis and 1 = 0 then motors ;every 2ms not sure what this does or what the intent is"
It was to test if bit 0 of millis was 0 or 1.
If it was 0 then it is an even number ie 2,4,6...18,20 ms...millis increases by 1 every 1ms.
so every even number call motors
when millis gets to 20 it would call motors as it's an even number and reset to 0 and call servo after 20 1ms interrupts ie 20ms.
Anyway I got it to work by using an every 2ms interrupt and changing the isr sub.
so the motors not working previously must be if millis and 1 = 0 then motors.
I feel chuffed I got it working. Chris, it works the same as using your millis.h but I cannot post code
using that so "re-invented"your wheel :)
The robot uses a V53L0X rangefinder and I tweaked the obtacle avoidance code from old code and added a last_turn variable.
Last edit: stan cartwright 2020-06-19
I have no objection to you posting or discussing the millis() function or code that uses it.
I was only asking that you don't publish code using the experimental DoEvery Statement.
I appreciate you beta testing it for me but, as I am still testing and optimising memory use on a range of devices so the syntax and use of DoEvery may change before I publish.
To show examples now may indirectly lock uys into a restrictive version in the future.
Last edit: Chris Roper 2020-06-19
Chris , I worked out my own doevery equivelant so I could post the code for the robot.
It is interchangeable, just comment out your doevery and use the interrupt or comment out the interrupt and use doevery.
Anobium, please explain pulseout 2200 us.
It's software so the program stops for at least 2200us...yes?
So if I use an every 20ms interrupt no problem...yes?
If I also calling another event every 2ms ie within the pulseout 2200us what happens to the program flow.
It doesn't "seem" to be causing a problem.
Chris, this applies to using your code to.
Cheers stan
PulseOut is a macro.
You can use every 20ms but ensure your interrupt does not use Wait as this will mess this up.
As Pulseout and therefore WAIT counts clock cycles (based on frequency) an interrupt of X cycles will impact PulseOut. The total number of clock cycles will be ( PulseOut cycles + X cycles in the interrupt ).
You will get 20 ms 'worth' of PulseOut clock transitions. So, this may be way is it working.
Last edit: Anobium 2020-06-19
Here's a video of the robot using 2ms interrupt. https://youtu.be/Y_ai0tc_rek
Here's the program code. You can see it's working in the youtube video.
You can also see Chris Roper's millis doevery commented out. It looks promising doesn't it?
Chris has lost sleep working on this.
I was up until 2.30am thinking what would I do if I was the robot and an obstacle appeared...and coding the thoughts :)
Please check the motors sub. It looks a lot but take around 8us to execute....no way..
but I only got a Hantek 6022BE.
Just got a £8 salae clone logic analyser, as someone on the forum suggested from ebay. may be more accurate.
Ok if I post as a project with reference to Chris's millis removed?
The idea that
sub isr
motors
mills = mills + 2
if mills = 20 then mills = 0 : servo
end sub
works was inspired by Chris Ropers's doevery a la amstrad basic I suggested to him.
I can see how he is doing it but not from his code which I find difficult to understand.
The sub isr could have various counters to different timed subs....groovy
What is needed here is the second User Interrupt function in the Do suite that I have been working on:
Set Pin On
DoAfter 20 Set Pin Off
Would perform the same function as
Pulseout (Pin, 20 ms)
But it would not use the Wait command and be 100% compatible with other interrupts as it is itself an interrupt.
BUT, that is part of the Library I am working on so is not yet ready for testing, hang in there Stan, the more I understand of your needs the more I can refine my thinking.
I will give it priority and try and get you some test code in the next couple of days.
Chris , you are making me feel guilty.
I have a hardware solution if I want from Mr Kent..very complicated but nice offered.
I don't get using wait..the interrupt still works.
That's how I use the robot- r_mot_left=forward : wait 200ms and the motors still turn.
Set Pin On
DoAfter 20 Set Pin Off
Would perform the same function as
Pulseout (Pin, 20 ms)
But it would not use the Wait command and be 100% compatible with other interrupts as it is itself an interrupt.
It's pulseout pin,2ms and would be variable from 500 us to 2500 us. 1500us centres a servo.
I think to simulate pulseout would need a every 10us interrupt.
I've used a servo interrupt before and a stepper motor interrupt before but not together
off 1 interrupt before. smug
Chris, I don't know why a servo needs pulseing it's position every 20msjust what I found researching.
I think it's for like if the servo is under strain eg a model plane's rudder driven by a servo and the wind resistance.
In my robot code the servo is not under stress so I removed the call to servo in the every 2ms isr
and pasted the contents of the servo sub at the end off the only code that controls the servo and
it is all working fine as before. The every 2ms interrupt is still needed for the motors to perform at peak speed and torque.
Hope your millis is working to plan.
would doafter be
get millis store as mil1
do event
is after=millis-mil1
checked in an interrupt often
To avoid further confusion:
Millis() is working fine and it has been working and included in GCBASIC for a few years now.
Millis() Uses Timer0 and a Long Variable to count the number of milliseconds since a device reset.
You were looking for an easy way to have user based timer interrupts, but as Timer0 was already used by the Millis any code that tried to use Timer0 would disrupt Millis.
What I have been working on is a way to share Timer0 between the existing Millis() function and the new requirement for a user based timer interrupt. As "millis.h" already has all of the code to set up Timer0 on all of the supported devices I used that initialisation code as the basis of the new user interrupts.
The new system is NOT using the millis() function nor does it alter the millis() function in any way you, and anybody else, can continue to use millis() in their code exactly as they always have. The Modified millis.h that I sent you just give an extra hook into the interrupt to allow DoEvery and millis() to coexist without conflicting over timer0.
The help and the example libraries along with any Arduino Documentation contain info on the use of millis().
The new functions are taking time because they have to be designed to work on many different devices and minimise the amount or RAM use, that takes time to design, test and rework the retest for several devices. They are NOT based on Millis() they are independent Methods.
The original Beta code I sent you was specific to your need - the resultant library will be generic.
So the bottom line is that I am NOT working on or with millis - this is a totally separate project to millis but will coexist with millis so that they can share Timer0.
So please USE millis(), do NOT try to create your own millis() function, millis() works now, it has worked for a few years and it has been extensively tested on hundreds of different devices.
DO NOT reinvent the wheel - the DoEvent Library, for want of a better name, is what I am working on, NOT millis() and as the wise man said “if it ain't broke, don't fix it”.
Chris-It's just a hobby. I can wait for for your ideas to be published.
More I experiment,more I learn. So... sorry. I will keep on experimenting with interrupt driven events for my own interests on a 328p or a 18f25k22, all I use.
Your doevery will be useful for making interrupts easier.
Hope the project works out.