Go Back  R/C Tech Forums > General Forums > Radio and Electronics
The Homebuilt Dynamometer (Dyno)Thread!!! >

The Homebuilt Dynamometer (Dyno)Thread!!!

Community
Wiki Posts
Search
Like Tree16Likes

The Homebuilt Dynamometer (Dyno)Thread!!!

Thread Tools
 
Search this Thread
 
Old 04-10-2024 | 06:05 PM
  #121  
trilerian's Avatar
Tech Elite
iTrader: (51)
 
Joined: Apr 2005
Posts: 2,393
From: Lexington KY
Default

Originally Posted by kufman
I agree that a 10Hz sample rate doesn't indicate which way it works. My friend bought their dyno several years ago and was able to determine that it was counting ticks instead of time between ticks. He wrote the company to convince them that the data was pretty bad because of this mode of measurement. They weren't willing to work with him on a fix at that time.
Well that is frustrating... I guess it makes sense why you get seismographs at higher sample rates.

Are you dead set on using the R4? Is it the 5V you are trying to stick to? Honestly I think the easiest way to go would be to use an ESP32 with an external ADC, like the ADS 1015 or mcp3204 if you want SPI. You can get those current sensors in the 773 which are 3.3V. Then you can get the Arduino ESP32 and pretty much port your code to it with the same footprint you have now. With the exception of the ADC, which is horrible on the ESP32.
trilerian is online now  
Old 04-10-2024 | 06:14 PM
  #122  
kufman's Avatar
Tech Elite
iTrader: (7)
 
Joined: Feb 2004
Posts: 3,787
From: Elburn, IL
Default

Originally Posted by trilerian
Well that is frustrating... I guess it makes sense why you get seismographs at higher sample rates.

Are you dead set on using the R4? Is it the 5V you are trying to stick to? Honestly I think the easiest way to go would be to use an ESP32 with an external ADC, like the ADS 1015 or mcp3204 if you want SPI. You can get those current sensors in the 773 which are 3.3V. Then you can get the Arduino ESP32 and pretty much port your code to it with the same footprint you have now. With the exception of the ADC, which is horrible on the ESP32.
Nope, I am open to ideas on how to do it best. I am not the best programmer in C. I prefer doing stuff with FPGA's but that makes communication with the outside world harder. Will using a SPI ADC interfere with using interrupts to measure RPM? Don't they both want to use interrupts?
kufman is offline  
Old 04-10-2024 | 06:35 PM
  #123  
trilerian's Avatar
Tech Elite
iTrader: (51)
 
Joined: Apr 2005
Posts: 2,393
From: Lexington KY
Default

Originally Posted by kufman
Nope, I am open to ideas on how to do it best. I am not the best programmer in C. I prefer doing stuff with FPGA's but that makes communication with the outside world harder. Will using a SPI ADC interfere with using interrupts to measure RPM? Don't they both want to use interrupts?
I'm not sure if the SPI uses interrupts, but it shouldn't be an issue. Most of them have a library, or you can bit bang them, which is what I default to. Using the ESP32, I think the clock is 80MHz and if the SPI hardware uses interrupts it isn't using the interrupt pins. Which on an ESP32 is most of them.

Out of curiosity, did you try lowering your baud rate for the serial connection when streaming the serial data simultaneously? I know a lot of people default to 112500, 9600 is slower by may not interfere as much.
trilerian is online now  
Old 04-10-2024 | 06:40 PM
  #124  
kufman's Avatar
Tech Elite
iTrader: (7)
 
Joined: Feb 2004
Posts: 3,787
From: Elburn, IL
Default

Originally Posted by trilerian
I'm not sure if the SPI uses interrupts, but it shouldn't be an issue. Most of them have a library, or you can bit bang them, which is what I default to. Using the ESP32, I think the clock is 80MHz and if the SPI hardware uses interrupts it isn't using the interrupt pins. Which on an ESP32 is most of them.

Out of curiosity, did you try lowering your baud rate for the serial connection when streaming the serial data simultaneously? I know a lot of people default to 112500, 9600 is slower by may not interfere as much.
I didn't lower the baud rate and I had the serial communication command in the isr so that it would only send a message when a new rpm measurement was taken. This is probably a bad idea but again, I am not a great programmer.
kufman is offline  
Old 04-10-2024 | 06:55 PM
  #125  
trilerian's Avatar
Tech Elite
iTrader: (51)
 
Joined: Apr 2005
Posts: 2,393
From: Lexington KY
Default

Originally Posted by kufman
I didn't lower the baud rate and I had the serial communication command in the isr so that it would only send a message when a new rpm measurement was taken. This is probably a bad idea but again, I am not a great programmer.
That would make your ISR take longer. Goal of the ISR, get in set a flag, make timestamp, etcetera, and get out. Leave everything else outside the ISR and use millis or micros to facilitate your sample rates. That way your ISR can interrupt your serial communication and your serial communication shouldn't hurt your ISR since you'll be doing it when the ISR is not happening.

But, doesn't matter if you are storing everything in an array and sending it later. Just takes up space.


To be honest, your curves look good, really smooth. So long as they are repeatable, everything else can be sorted out by the mcu choice and peripherals you decide to go with.

EDIT: SPI does not use interrupts, but I2C does.
gigaplex likes this.
trilerian is online now  
Old 04-11-2024 | 02:22 PM
  #126  
kufman's Avatar
Tech Elite
iTrader: (7)
 
Joined: Feb 2004
Posts: 3,787
From: Elburn, IL
Default

Originally Posted by trilerian
That would make your ISR take longer. Goal of the ISR, get in set a flag, make timestamp, etcetera, and get out. Leave everything else outside the ISR and use millis or micros to facilitate your sample rates. That way your ISR can interrupt your serial communication and your serial communication shouldn't hurt your ISR since you'll be doing it when the ISR is not happening.

But, doesn't matter if you are storing everything in an array and sending it later. Just takes up space.


To be honest, your curves look good, really smooth. So long as they are repeatable, everything else can be sorted out by the mcu choice and peripherals you decide to go with.

EDIT: SPI does not use interrupts, but I2C does.
Yes, the curve I posted is a good curve but it isn't the way the SimpleDyno software measures it. Also, it is a fairly short set of data due to the limited ram. Since I only use the Arduino IDE for programming, the chip manufacturer makes no difference to me. I think it is possible to trick the SD software to accept a file made from my array setup but I haven't done it yet. Since the Minima has 16x the memory, I should be able to get a full set of data with RPM, voltage and current. Still messing around with different ideas which is what makes it fun!
kufman is offline  
Old 04-11-2024 | 04:48 PM
  #127  
trilerian's Avatar
Tech Elite
iTrader: (51)
 
Joined: Apr 2005
Posts: 2,393
From: Lexington KY
Default

Originally Posted by kufman
Yes, the curve I posted is a good curve but it isn't the way the SimpleDyno software measures it. Also, it is a fairly short set of data due to the limited ram. Since I only use the Arduino IDE for programming, the chip manufacturer makes no difference to me. I think it is possible to trick the SD software to accept a file made from my array setup but I haven't done it yet. Since the Minima has 16x the memory, I should be able to get a full set of data with RPM, voltage and current. Still messing around with different ideas which is what makes it fun!
Do you have the R4 (Minima)? You should be able to just port the code over. That is one of the good things about Arduino. The pinout on it should be the same as the Nano.
trilerian is online now  
Old 04-11-2024 | 04:55 PM
  #128  
PDR's Avatar
PDR
Tech Elite
iTrader: (31)
 
Joined: Oct 2008
Posts: 2,207
From: Sydney, Australia
Default

I'm happy to contribute what I can to this. For example, I've got a datalogging board that captures a bunch of stuff at 50Hz and writes it to a microSD card as it goes, so it can record practically forever (well, not really, but in RC terms, I've captured whole runs at 50Hz. Current version of the hardware captures battery voltage, motor RPM, throttle input and acceleration in 3 axes.
kufman likes this.
PDR is offline  
Old 04-11-2024 | 05:20 PM
  #129  
kufman's Avatar
Tech Elite
iTrader: (7)
 
Joined: Feb 2004
Posts: 3,787
From: Elburn, IL
Default

Originally Posted by trilerian
Do you have the R4 (Minima)? You should be able to just port the code over. That is one of the good things about Arduino. The pinout on it should be the same as the Nano.
Not yet but they aren't that expensive.

I'm happy to contribute what I can to this. For example, I've got a datalogging board that captures a bunch of stuff at 50Hz and writes it to a microSD card as it goes, so it can record practically forever (well, not really, but in RC terms, I've captured whole runs at 50Hz. Current version of the hardware captures battery voltage, motor RPM, throttle input and acceleration in 3 axes.
Sounds pretty cool and it might work for a dyno setup but the RPM needs to have a bunch of points in the first few rotations. That is why I am trying to capture on a turn by turn basis instead of a fixed sampling frequency. Can that be done with your setup?
kufman is offline  
Old 04-11-2024 | 05:45 PM
  #130  
trilerian's Avatar
Tech Elite
iTrader: (51)
 
Joined: Apr 2005
Posts: 2,393
From: Lexington KY
Default

Originally Posted by kufman
Sounds pretty cool and it might work for a dyno setup but the RPM needs to have a bunch of points in the first few rotations. That is why I am trying to capture on a turn by turn basis instead of a fixed sampling frequency. Can that be done with your setup?
Actually what I think @PDR is suggesting would allow you to offload your data every 50Hz so you can clear your array and save memory. You wouldn't be recording at 50Hz, just offloading. Most likely an SPI interface.

EDIT: I could be wrong, but that seems like the direction to try and take.
kufman likes this.
trilerian is online now  
Old 04-11-2024 | 05:55 PM
  #131  
PDR's Avatar
PDR
Tech Elite
iTrader: (31)
 
Joined: Oct 2008
Posts: 2,207
From: Sydney, Australia
Default

Originally Posted by kufman
Sounds pretty cool and it might work for a dyno setup but the RPM needs to have a bunch of points in the first few rotations. That is why I am trying to capture on a turn by turn basis instead of a fixed sampling frequency. Can that be done with your setup?
The current design captures only one sensor from the motor (ie: one revolution), but could be extended to look at all three. It would work by measuring time between pulses and can be accurate down to CPU clock rate (eg: 1/20th microsecond). Sometimes need to be careful if the rate is too low, because you can get overflow, but there are tricks for dealing with that.
kufman likes this.
PDR is offline  
Old 04-12-2024 | 06:10 AM
  #132  
kufman's Avatar
Tech Elite
iTrader: (7)
 
Joined: Feb 2004
Posts: 3,787
From: Elburn, IL
Default

Up above I showed RPM data when it is dumped into an array. Here is what it looks like when captured by the Simple Dyno sketch. The curve fitting takes care of the mess but it could be better.
kufman is offline  
Old 04-13-2024 | 08:14 AM
  #133  
kufman's Avatar
Tech Elite
iTrader: (7)
 
Joined: Feb 2004
Posts: 3,787
From: Elburn, IL
Default

I did a bit more testing on the number of pickups for the RPM measurement. I think the noise comes from two things. 1-The holes in the disk are not perfectly 90 degrees apart. 2-The jitter in the interrupt command on the Arduino Nano is about 10 to 20 usec.

I was able to look at the RPM measurement with my scope and I can see that there is jitter. If I trigger the scope on the rising edge of a pickup, I can see the next 3 pickups jitter in time but the 4th (which is the first one again) is perfectly still. It isn't hard to believe that the disk isn't perfect. It is only 3d printed and I had to put tape over it to make it work (PLA is tranparent to infrared light). I then had to use an Xacto to cut out the holes again. I am sure there is some slot in the dimensions.

The interrupt jitter in the Arduino is another problem. I want at least 4 pickups per revolution so that the low RPM data is captured but that makes it harder for the Arduino to time accurately. If you only use 1 pickup, you will get redundant measurements (i.e. if measurements are taken every 20msec and you are lower than 3000rpm, you will get two identical data points). This can be seen in the power curve for the 1 hole disk. 4 holes seems to be the best but the rpm gets pretty sloppy at higher RPM's. The plots below at 4 holes, 2 holes and 1 hole respectively.





kufman is offline  
Old 04-13-2024 | 08:16 AM
  #134  
kufman's Avatar
Tech Elite
iTrader: (7)
 
Joined: Feb 2004
Posts: 3,787
From: Elburn, IL
Default

Here are the resulting power and torque plots. Notice the flat sections on the 1 hole plot.

kufman is offline  
Old 04-13-2024 | 08:25 AM
  #135  
kufman's Avatar
Tech Elite
iTrader: (7)
 
Joined: Feb 2004
Posts: 3,787
From: Elburn, IL
Default

By the way, here is the sketch for the Arduino.
//
//
/*
Sketch for use with SimpleDyno
Developed on Arduino Uno Platform
DamoRC - 2013-2014

ALWAYS use the Sketch distributed with each new version of SimpleDyno

Transmits:
1 x Session timestamp
1 x Interrupt timestamp and 1 x time interval since last interrupt for INT0 / Pin2 / RPM1
1 x Interrupt timestamp and 1 x time interval since last interrupt for INT1 / Pin3 / RPM2
6 x Analog Inputs (A0 and A1 are Voltage and Current, A2 and A3 are Temperature, A4 and A5 are open)
Values are comma delimeted
Baud rates selected in SD must match coded values in this Sketch.
*/

const int NumPortsToRead = 6;
int AnalogResult[NumPortsToRead];
volatile unsigned long TimeStamp = 0;
volatile unsigned long time1 = 0;
volatile unsigned long time2 = 0;
volatile unsigned long Oldtime1 = 0;
volatile unsigned long Oldtime2 = 0;
volatile unsigned long TempTime1 = 0;
volatile unsigned long TempTime2 = 0;
String AllResult = "";

void setup() {
// Initialize serial communication
// Ensure that Baud rate specified here matches that selected in SimpleDyno
// Availailable Baud rates are:
// 9600, 14400, 19200, 28800, 38400, 57600, 115200
Serial.begin(115200);
// Initialize interupts (Pin2 is interrupt 0 = RPM1, Pin3 in interrupt 1 = RPM2)
attachInterrupt(0,channel1,FALLING);
// attachInterrupt(1,channel2,FALLING);
}

void loop() {
AllResult = "";
AllResult += micros();
AllResult += ",";
AllResult += TempTime1;
AllResult += ",";
AllResult += time1;
AllResult += ",";
AllResult += TempTime2;
AllResult += ",";
AllResult += time2;
for (int Looper = 0; Looper < NumPortsToRead;Looper++){
AnalogResult[Looper] = analogRead(Looper);
AllResult += ",";
AllResult += AnalogResult[Looper];
}
Serial.println (AllResult);
Serial.flush();
delay(20); //20 is default
}

//Interrupt routine for RPM1
void channel1(){
TempTime1 = micros();
time1 = TempTime1-Oldtime1;
Oldtime1 = TempTime1;

}

//Interrupt routine for RPM2
//void channel2(){
// TempTime2 = micros();
// time2 = TempTime2-Oldtime2;
// Oldtime2 = TempTime2;
//}
kufman is offline  


Contact Us - Archive - Advertising - Cookie Policy - Privacy Statement - Terms of Service -

Copyright © 2026 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.