I want to use UNO R4 WIFI on a 2-wheel balance robot. It's potentially great because it is fast, has onboard IMU for balance, and it has WIFI / BT.
Usually, a 2-wheel robot uses two 1 usec or 0.5 usec timers to control the motor speed. The problem is I don't see documentation on using the timers.
Is it possible to get two 0.5 usec timers with this board?
Is there documentation somewhere for how to use the timers?
Are there examples somewhere on how to use them?
Sure would be a nice little robot controller with something like a motor shield or CNC shield on top for stepper motors.
I wonder if you mean that the timer has 0.5usec resolution, with maybe a count to 256 and repeat. That would give you a period of 128usec, or about 8KHz. So the PWM output would go high at time 0 (unless a duty cycle of 0 was being called for) and then it would stay high for any number of intervals up to 255. Perhaps that means there need to be 255 intervals total, not 256. But anyway, not a 2MHz frequency.
The actual speed needed to drive the steppers is 180usec to 2000usec.
With step pulses at 180usec intervals the robot will be moving quite fast.
with 2000usec (2ms), it will be crawling.
So, my revised questions are:
Is it possible to get two timers that can be varied from 200usec to 2000usec?
Is there documentation somewhere for how to use the timers on this board? Are there examples somewhere on how to use them?
I'm actually updating my MobaTools library to support the UNO R4. It will be definitely able to create stepper pulses up to 180µs ( probaly even a bit faster ). It will be able to drive up to 6 steppers with that speed.
So how urgent do you need it ? I may still need a bit time to get it released. ( Beta testers are always welcome )
I'm using the FSP to select a free timer, but then i configure it directly, because the FSPTimer class doesn't support the needed timer mode.
Well, I only use the static methods to select a free timer and reserve it. I think, when implementing a library that maybe better, to coexist with other libraries that may use the FSP. I don't create any FSPTimer object.
No, I'm using the GPT timer just like I use the timers in other supported boards. I need a completely unbuffered mode for the compare registers to create compare interrupts at any time.
Delta_G,
as long as you can choose 2 timers without interrupting millis() and micros(), I'm good with it.
I noticed how easy it was for people to respond once I said what I wanted to do with this.
That made me think a spec for exactly what a 2-wheeled stepper-based library ought to do to would be helpful. That would help in creating the library and simplify creating these robots for beginners. It would obviously be initially focused on the R4 WIFI because it is a good platform to use as a starting point and might later expand to other boards. These robots also need a shield with 2 stepper drivers, an IMU for the angles and acceleration, and a PID controller. Servos are a good way to get the robot to stand up on its own when it falls down.
Such a library would start with everything necessary to control the steppers and possibly expand to a library that includes what is needed for the IMU, steppers, servos, and communications.
Right now, I know of a couple choices for the stepper shield, but none that I know of that include an IMU so that would be a simple add-on to the design.
I am very interested in balancing things and have has some past marginal success, the problem is I am only a hacker type programmer, but I understand fairly well what is needed to make these work. Perhaps, if anyone else on here is interested in balancing objects, they could help.
I could take a stab at such a spec, and perhaps open a new post to gather corrections and updates.
If you are interested I can upload the development2.6.0 branch on GitHub, so that it reflects the current development state. With e.g. the GPT configuration.
It's definitely 'in development' with a lot of debugging features enabled. But stepper and servo should basically work on R4 already.