1 or 2 Arduino's needed?

Sareno:
Putting on a single port... thats over my head I guess. Maybe you can send me a link with more info?

Port manipulation tutorial.

Can give huge performance advantage for fast, repetitive tasks as a digitalRead() ro digitalWrite() call takes a few µs to complete and these calls just a single clock cycle - that's 62.5 ns.

Use with care, as it does make program maintenance a lot harder: it's not just because we normally use those functions instead!

lastchancename:
haha...
I wasn’t talking about code revisions !

Tell me..:slight_smile:

Finally, I re-found my topic..

I managed to find very small and light magnets so would like to use 1 magnet per axle.

What kind of hall sensor should I use? pref non-latching. There are so many out there that I am lost. It has to be fast and non-latching.

I was wondering what type of Hall device you referred to, the analog sensor or the cheaper digital switch? And a digital INPUT can turn a sensor into a switch.

If you are counting turns the Hall switch will do better since a digital read can be done in 1 cycle using direct port access or about 5 cycles using made-safe Arduino digitalRead(). Direct port access is easy to read safe after using Arduino pinMode() once in setup. If you want to change modes during runtime, take care.

You can read 6 pins digital on Uno ports, 2 pins of each are tied up.

If you want to mount a DIP on your own board you could try the 40 pin ATmega1284P-PU. It should cost less than 2EU in your market. It gives 4 8-bits-open ports, 32 IO pins. First taken up are usually RX and TX, the rest by feature but all can be digital pins.

With 1 port that could read all 7 sensors as 1 byte in 1 cycle and update counts on change detections in not many microseconds. Read and reset the counts at regular times, what makes sense depends on how fast the sensors turn.

1284P has 2 UARTs, 128K flash, 16K RAM, 4K EEPROM.

It's not a 2560 though, those support external RAM up to (64 - 8)K per bank. Crossroads sells breakouts, IIRC.

If you have a red or IR led and IR detector, a slotted wheel on the turning shaft could let you count arcs of turn. With 2 sensors you could get direction. This would be more accurate at low RPM.

A magnetic version of that is a gear counter. You can DIY a gear counter.

I was looking for a unipolar hall sensor that detects and counts the moments that the magnet passes it. This way I only have to detect once per rotation.

Why can I read 6 digital pins? The uno has 13 digital pins or do I miss something?

Will the 1284P work together with an Uno or Nano?

Anyway, it has to (edit) detect the revelations and once every 100ms or so, calculate the RPM.

Basically, it needs to detect how long ago the last detection was, this way I can calculate the RPM. So it only has to "remember" the last detection as wel as the shortest (highest RPM). Then, every 100ms or so, write the RPM to SDCard. Or into a variable and then once a 1 second, clear that VAR to SD.

GoForSmoke:
If you have a red or IR led and IR detector, a slotted wheel on the turning shaft could let you count arcs of turn. With 2 sensors you could get direction. This would be more accurate at low RPM.

A magnetic version of that is a gear counter. You can DIY a gear counter.

I do not have room for IR setup and I have no slotted wheels. Also, the RPM will not be low.

Why can I read 6 digital pins? The uno has 13 digital pins or do I miss something?

The comment was in respect of reading input ports directly which can be very fast. Each port has 8 bits but only 6 of the pins of each port can be read at the same time because some of the port bits are used for other purposes

Oh, ok.

Thanks.

Sareno:
I was looking for a unipolar hall sensor that detects and counts the moments that the magnet passes it. This way I only have to detect once per rotation.

Why can I read 6 digital pins? The uno has 13 digital pins or do I miss something?

ATmega chips are 8-bit machines. The ports have 8-bit registers, the CPU can only work on 8-bits at a time.

Have you ever seen a pin map for an Uno?

Will the 1284P work together with an Uno or Nano?

The Uno is a board with a 28-pin socket that can use ATmega48, ATmega88, ATmega168 and ATmega328.
The Nano is a board with a surface mount ATmega328.

The ATmega1284P is a bigger microcontroller with the same CPU as the others, you can make your own Duino with one the same as you can with an ATmega328. 1284 is 328's big cousin, either can run on their own. The 1284P will let you read 8 inputs in 1 cycle, 62.5 nanosecs quick.

Nick Gammon shows how to breadboard either chip.

Anyway, it has to (edit) detect the revelations and once every 100ms or so, calculate the RPM.

Basically, it needs to detect how long ago the last detection was, this way I can calculate the RPM. So it only has to "remember" the last detection as wel as the shortest (highest RPM). Then, every 100ms or so, write the RPM to SDCard. Or into a variable and then once a 1 second, clear that VAR to SD.

If you try and time single detections you will end up needing to average 10+ since Arduino micros() has a granularity of 4 microsecs and interrupts have an overhead over 5 microsecs on top of the ISR code. Also the faster the magnet moves the stronger the effect on the sensor.

You want RPM 10 times per second? That should be 100's of revs to average out one time +/- 3 usec error.
How fast will these sensors change spin rate anyway?

For light, a slotted wheel can be laser printed black on transparency at an office store. The diameter can be smallish and one printed sheet can have many such on it. The wheel lets you be more accurate, divides error.

Hi,
Are the 7 shafts you want to measure on your RC all connected through a gearbox, or are they on individual drive motors?

Can you post a block diagram of your RC car and show what sensors you are monitoring?

Thanks.. Tom.. :slight_smile:

Thanks for all the replies. I thought that I had it figured out but now I am in doubt again. This proves to be more complicated than I thought.

Do you have an example of such a slotted wheel setup, I mean the sensors involved? Again, there are so many options out there.

10 times a second is just a guess btw. I only need (want) the real time RPM from 1 axle (motor). The others are for reference only or for later examination. BUT, because most of the time at least 1 or 2 wheels are spinning I need the slowest to calculate the speed and the distance that I have driven (slowest has most grip so is best to use for actual speed).

I can create a block diagram later on but may you get what I mean by this:

Front:

Left Wheel ---1---- Diff ---2---- Right Wheel

Mid:

Front diff ---3---- mid diff---4----Rear diff

Rear:

Left Wheel ---5--- Diff ---6---Right Wheel

Motor axle (connected to midd diff) = 7

In short; the motor drives the midd diff. From that point on the power is being distibuted through 3 diffs to the wheels. It is an off-road 1:8 Truggy with a lot of power (top speed should be around 100KM/H).

Just as an experiment and to learn (and because it can be fun!!) I want to be able to:

Read Engine RPM Realtime
Log Max RPM
Read realtime speed
Log Max speed
log acc time 0-xxx
Distance driven
Analyze wheel behaviour. When does a wheel (and which) spin? This can help me to setup the suspension or gearing.

I have enough room for Hall sensors like the A3144 but I really doubt I can place slotted wheel setups.

What about the Arduino DUE?

Hmm, on the first page of this thread we already discussed the DUE and Micro.

I read somewhere that the DUE would be End Of Life but now I see that I can still order it.

The 1284P does not look that powerfull on paper (spec-wise). But I do not know about the inputs per cycle of those other boards.

You have a linear Hall sensor that you can read digital (the pin will go LOW to HIGH at around 2.8V and go HIGH to LOW at around 1.1V, word is hysteresis) in groups of up to 8 in nothing flat (1 cycle) ---- or ---- you can read it analog which going from analog pin to analog pin reading different sensors means pin settle time before the read (the chip doc recommends doing 2 reads but only keep the second) and you can get a good read about every 3400 cycles.

Analog read is dead slow compared to digital read.

Hall switch costs about 50 cents where linear Hall sensor costs about 3x as much. For what you want, the switch is good.

Gear tooth counter: https://www.westfloridacomponents.com/blog/how-do-sensors-measure-gear-tooth-speed-and-direction/

Ferrous metals soak up magnetic field. You can use a linear Hall sensor to see this by putting it aligned in a magnetic field and then bring a piece of steel in to the side to bend the field out of line with the sensor axis (Hall sensor only senses along one axis) and cause the Hall to output lower voltage than when aligned.

You can buy a gear tooth counter, shop around and you might find one for less than $20.

I really don't think that you appreciate how fast AVR chips are. You should be able to read and process 8 digital signals 40+ times per millisecond using simple non-blocking code including direct port reads.

I don't think that you know these chips well and I can't see picking a chip and strategy on slim knowledge.

Sareno:
I read somewhere that the DUE would be End Of Life but now I see that I can still order it.

You also can use a smaller DUE compatible module

duecore.png

Due R3 Core For Arduino Compatible SAM3X8E 32bit ARM Cortex M3 Module UC-2102 512K Flash 96K RAM 12bit ADC 12bit DAC 84MHz

for around $20. This vendor also has a nice Mega compatible module.

duecore.png

Clearly, I have some homework to do. Thanks.

I another thread I was advised to 3d-print some parts to put on the shafts with a magnet and a hall sensor. I will look into the gear counter but again, I do not think I have the space for it.

I will be re-building the car somewhere this week and I will post some pictures to give you an idea of size and space.

Something else just occured to me. Those high RPM's are not for all shafts. The diffs have gearing.

So, The max RPM of the motor is (in theory) 50.000 but that is only 1 shaft.

The main spur gear and pinion are 63 and 18: 1;3.5
The max RPM of the 2 midd axles is: (50.000/3.5); 14285 RPM
The spur and gear of the 2 end diffs are 43 and 13: 1;3.3
The max RPM of the wheel axles is (14285/3.3): 4328

I might be changing some gears but these numbers will give you a way better idea of the real situation. I might change the main spur for a 48tooth but even then, the RPM will never be higher than 16000, except the motor.

Could you send me a link to a sensor that I can use with a slotted wheel? I tried to google but all I find are quite big.

What kind of small sensor would I need? I might be able to 3d print small slotted wheels to mount on the axles.

In the gear tooth counter article it showed a plastic gear with a thin metal gear on one side to work with a Hall switch.

Without the metal an IR led on one side and detector on the other works as long as the gear is opaque.

There's principles at work in these. Iron grabs magnetic field, changes the strength. Light is blocked or not by the gear tooth. Principles that you apply to fit your car.

Magnetic sensing is not blocked by dirt where a led and detector can get covered with dust/mud. Principles.

If you need extra fast, the Teensy 4.0 is a 32-bit MCU that runs at 600MHz and costs about $20 + shipping. Caveat is that the board is 18mm x 36mm with closely spaced components and contact pads on the underside (rather than pins). Your soldering skills must be very good to attach anything to it. Also the pins are electrically weak, 3.3V with small current limit... AVR pins are much more hobbyist friendly.

I figured that a thin metal gear or slotted wheel shape could be put on the inside side of each car wheel hub and sensor on the wheel suspension to go up and down with the wheel. The shape does not get used as a gear, just has regularly spaced bits that stick up and grab the magnet field.