I have a question regarding how best to sample data from multiple sensors when they are all updating at different/changing rates. I am new to data acquisition so please bear with me. For my Master's research, I am trying to build a dynamometer to measure the performance of a belt transmission used with the Baja SAE team at my university. This is a VERY low budget project, so I am trying to collect data with arduino/raspberry pi if possible. The test setup consists of a drive pulley attached to an engine and a driven pulley with a friction brake behind it. I am trying to measure the RPMs for both shafts, and the torque on the driven shaft. To measure RPM's, I have magnets mounted on the shaft and I am using hall effect sensors to measure the time between rotations. To measure the torque I have strain gages with slip rings.

The problem is that all sensors update at different rates. The drive pulley rotates at about 60Hz, and the driven can vary from 20-120Hz, with the values being measured once per rotation. The A/D converter for the strain gages reads at a constant 125Hz (the input voltage has a low pass filter to remove engine and other higher frequency noise-I am only interested in time averages). My goal is to be able to get a plot of the steady-state driven pulley torque vs speed.

I tried initially reading all of the sensors simultaneously with a raspberry pi, but all of the sensors are read with interrupts in the python code and the timing was off since it is not a real time device (the RPM data was VERY noisy). If I read each RPM sensor and the A/D converter individually with an arduino, it has no problem keeping up and the data looks clean. Now that I have all of the sensors reading, I am trying to put it all together. Since the reaction time of the transmission to a changing load is fairly slow, I think I could capture enough information if I sampled at 20-25Hz.

My question is if it would work to have separate arduinos reading each of the sensors continually and updating global variables in their RAM, then calling these current running values from the raspberry pi at a fixed sampling rate (20-25Hz). I didn't know if it would be a problem that I don't have timestamps for when the global variables last updated. I will not be using any kind of frequency analysis on the data. Also, to reduce noise from the strain gage A/D converter, could I have that global variable be a running average of the last, say 5, data points so that I am capturing information from each sample even though I am only calling values at 1/5 of its sample rate?

  • $\begingroup$ Are all of your sensors analog? (Even the RPM counters I mean) $\endgroup$ – A_A Mar 22 '18 at 6:43

My suggestion is to use a single Arduino for all the sensors, create timestamps for the data and transmit it via I2C to whatever sink you want. Your sampling rates are so low, that a single uC should do the job. Then do a generous oversampling to make data from different sensors easy to synchronize.

  • $\begingroup$ Thank you for your reply. So you are saying that it would be better to sample the arduino at a higher rate, maybe 500-1000Hz so there is less uncertainty in time for when the measurement updated? So I would be reading the same value multiple times until it updated? The driven RPM is used in a feedback loop, so would this affect the performance of the PD controller attached to it? Part of my question was also whether or not there is generally an acceptable level of desynchronization in data. So in this case, the possible error due o sampling at 20-25Hz would not be acceptable? $\endgroup$ – user34578 Mar 21 '18 at 12:40
  • $\begingroup$ What I meant is that the arduino should sample at the low rates, but with timestamps. The oversampling can be done on a computer and is just to synchronize the data. $\endgroup$ – Max Mar 21 '18 at 14:55
  • $\begingroup$ Just trying to figure out timing- If I transmit all of the data in a block by I2C, each timestamp would be 32 bits (long int) and each measurement would be 16 bits (all are integers). So each time I called a value from the computer I would need to send 96 bits plus the device address. I think I2C is typically at 100kHz, so that would take 1.1ms. What would happen if one of my RPM interrupts occurred in that time? Or if it occurred while I was reading the strain gage? I guess I'm just wondering if a single arduino can keep up with all of that- I don't know what its limit is. $\endgroup$ – user34578 Mar 21 '18 at 19:03
  • $\begingroup$ I2C can be cranked up to 400kHz, but I dont think that will be necessary. The creation of a time stamps takes just a few operations and the atmega runs at 16MHz. Once the timestamp is in memory, everything should be safe. $\endgroup$ – Max Mar 21 '18 at 20:03
  • $\begingroup$ Thanks for the help! I finally got it coded and it looks like everything is working. Every now and then one of the readings gets garbled in the transmission but it should be easy to pick out and exclude those points. $\endgroup$ – user34578 Mar 22 '18 at 19:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.