ArduEbike - Arduino Ebike projects

I'm still learning how bits are written in various bases. if arduino outputs from 0-255, it must be in base 8. according to above link, it can store 1023 values in base 8. This makes (15*60/1024) for a 1.137Hz sample rate over 15 minutes.

I'd save the difference between the winding temperature and stator ID steel if that's what I have to do to cram the data in. Two separate would be ideal, but I would assume the copper would always be hotter than the stator ID steel.

So I will probably do a 50-150C degree range in 2 degree increments (but read at full accuracy).. or whatever is best to get good resolution (say .1Hz) over 15-20 minutes. The delta T could easily always be a single digit number... testing will see

how easy will it be to extract the data? Can that be done with a simple linux program and the USB-serial adapter? Or you just plug it in to the arduino program and uncomment that line you mentioned and print in the serial viewer? I guess not comment out because every time you flash it you lose EEPROM data... so I would leave it in the original program with the serial.print function.
 
You can store a umber from 0..255 or -128..127 in a single byte of EEPROM... A single precision floating point number takes 4 bytes.
 
One byte could give 0-255 degrees C, not bad for what you need.

I don't think EEPROM is getting erased on program load. My params seem to stay during sw loads.

You can make a function that reads EEPROM and writes to serial port and capture it with a linux terminal window running tip, or a python program reading the serial port.
 
Should be 63 counts at 25C. Funny way to graph with an offset, but looks okay at that point. The rest seems reasonable but I did not go through the calcs.

You probably want to shift 2 bits right to get the result to fit in one byte.

You could set up your program this way:

setup()

scan through the EEPROM and print out the values < 255 (since erasing the nvram sets it to 255)
Send them to the serial port
stop at the first 255 value


loop()

read the temperature

If temperature > 40 write to EEPROM and go to the next location

delay till next reading time
 
Wow, just found this thread, and I gotta say, I'm blown away with the prospect of being able to reprogram on the fly. It's true that a cycle analyst can adjust some of the parameters on the fly, but you could imagine a 3 speed switch, which would allow for a quick reprogramming to offer current limit changes on the fly without a cycle analyst.

MWKeefer, I'm very interested in your 2wd project 2 controller management project. Do you have any more info on it?
 
Got it working... after I went on my test ride. Tomorrow I should have some graphs. I ended up writing to 0-511 and 512-1022 registers separately.. so I can easily copy and paste huge sections of separate data into excel.
 
Great. Not sure what you mean there, but whatever works. That's a good high temperature thermistor for a fairly reasonable price. I think the one I found was 200C and somewhat cheaper, but these 300C units are still pretty cheap.

I did some code cleanup today on the controller parameter programming code, need to find some wire for a cable. The serial code is half written now as well. Unfortunately the controller cannot be loaded "on the fly", but it doesn't take long to turn it off, load parameters, and then turn it back on. Could probably do it at a stoplight easily enough. :)
 
At least for this temperature range, diodes like 1N4148 are even cheaper as temperature sensors and seem to me that are much more linear than thermistors. Package is the same as that thermistor.

That thermistor has 5% tolerance, so at 25ºC it can be in 23.75ºC to 26.25ºC, a +-1.25ºC accuracy error. I think you can easily get into this kind of accuracy by manually calibrating a diode with a good ambient air or body thermometer.

More practical stuff here.
 
I was just going to second what Njay said. RTDs (thermal diodes) are much more reliable although they have a less-linear output over temperature. I think you could easily account for this in code.
 
Njay said:
At least for this temperature range, diodes like 1N4148 are even cheaper as temperature sensors and seem to me that are much more linear than thermistors. Package is the same as that thermistor.

That thermistor has 5% tolerance, so at 25ºC it can be in 23.75ºC to 26.25ºC, a +-1.25ºC accuracy error. I think you can easily get into this kind of accuracy by manually calibrating a diode with a good ambient air or body thermometer.

More practical stuff here.

Great tip! I've seen folks using diode for temperature sensors but never looked into it. Looks like setting the Arduino ADCs for 1.1V full scale would give a 1mV resolution which would yield about an 0.5C step. The value changes about 2.2mV per degree C.

Of course if you already have a thermistor in the motor it is not worth taking the motor apart to change it to a cheaper diode. :)
 
It would be easy to add code to my Controller Programmer to display ambient temperature and more than one other temperature sensor. This would make it useful when not programming the controller, which is most of the time. Three sensors would seem to be interesting - ambient, controller and motor. Perhaps two sensors in motor - axle and coils.

To store much data I would have to reduce the memories available for programming parameters to save some EEPROM for data storage. Even just saving the peak and average values and having a reset function would be pretty useful. Perhaps store the peak from each on-period, this would not take much space but give a nice picture of usage peaks.

In addition to ferrites a bypass capacitor would help reduce noise. Averaging a few thousand readings does amazing things for noise as well.
 
hmm... one of the thermistors I think I damaged. it is 8.6K Ohms when the other is like 9.35K Ohms. Maybe I should shift the bad one 10C.. it should be near 0 at beginning. shifted is below... might need to change out that thermistor ( I used it for testing once with direct soldering iron contact)
 

Attachments

  • test2.jpg
    test2.jpg
    39.1 KB · Views: 2,001
  • test3.jpg
    test3.jpg
    37.2 KB · Views: 2,001
Something is wrong. (deleted). I seem to fix the previous problem.... but now the offset is reversed. Last ride I shifted the blue curve down 10 degrees. This time, to start at the same temperature I would need to increase it about that much. You think it takes longer than 2 hours to cool a hub motor? Why all of a sudden am I starting at 100C?

Code:
 for (int i=0; i<511; i++){
        Winding = 0;
        for (int i=0; i<20; i++){
          Winding = Winding + analogRead(WindingTherm);
          StatorID = StatorID + analogRead(StatorIDTherm);
          delay(2);
        }
        Winding = Winding/20;
        StatorID = StatorID/20;
      
        Winding = map(Winding, 0, 1023, 0, 255);
        StatorID = map(StatorID, 0, 1023, 0, 255); 
        Winding = constrain (Winding, 0, 255);
        StatorID= constrain(StatorID, 0, 255);
//        Serial.print("Winding = ");
//        Serial.println(Winding);
//        Serial.print("ID = ");
//        Serial.println(StatorID);
        delay(2000);
        EEPROM.write(i,StatorID);
        EEPROM.write(i+511,Winding);
      }
 

Attachments

  • ugh.jpg
    ugh.jpg
    40.2 KB · Views: 1,995
Yeah... I will order more. But even still... starting at 117C doesn't sound accurate for the good thermistor. All I did was change my sampling interval

to calibrate them I need two data points. should I dip them both in boiling water and note differences? then do same at room temperature?
 
Did you measure them both with a meter? What are the chances that there is some goofy bug in play here?
 
Back
Top