|
Post by Ben Shaw on Jul 15, 2020 15:11:03 GMT
We have been fiddling with the eChook code all day today, with our limited knowledge and help from you we seem to have figured out something that works for us. the unchanged 'short code transit interval' is set to 250 milli secs, however we found that changing this value from 250 to 500 has worked better for us. although the update time will be slower this also means the RPM will go up in 30 rather than 60 with making little sacrifice to the rest of the values. this also looks much better on the phone and freeboard as more accurate data is given.
const unsigned long SHORT_DATA_TRANSMIT_INTERVAL = 500; // transmit interval in ms
thanks, Ben
|
|
|
Post by keduro on Jul 15, 2020 17:20:29 GMT
Ben, A couple of thoughts if I may (and Rowan, keep me straight here if I'm misrepresenting anything in the eChook code :-)). In the stock code (i.e. that on github), the motor rpm is measured every 4th multiple (line 350) of the SHORT_DATA_TRANSMIT_INTERVAL (line 302), i.e. every 1 second. As Rowan says, the number of motor revolutions is multiplied by 60 (line 620) as part of calculating the RPM. The number of revolutions is divided by the time interval as part of calculating the RPM (line 627) - this is ~1 (not always as there can be slight variations in elapsed time (*)). so the RPM increments/decrements in sixties. If, as you have done, you increase the SHORT_DATA_TRANSMIT_INTERVAL to 500ms then the time interval increases to 2s instead of one second, so the RPM then increments/decrements in thirties. However ... you can improve on the resolution by modifying line 618 from: float motorRevolutions = tempMotorPoll / CAL_MOTOR_MAGNETS;
to float motorRevolutions = (float)tempMotorPoll / CAL_MOTOR_MAGNETS; By adding the '(float)' in front of tempMotorPoll it forces the calculation to be done as a float, rather than as in integer. For example, if tempMotorPoll were 317 and CAL_MOTOR_MAGNETS is 3, then the original calculation yields 105, whereas the modified calculation yields 105.67. By doing this you can improve the original code to increment/decrement RPM in twenties, or your modified code to increment/decrement RPM in tens. Rowan ... have I missed something? I haven't tested this (our cars are still locked down here in Scotland) - but I am going to make implement this change on our eChooks. -- Keith. (*) I have looked at real data logged from one of our cars and the increments/decrements vary between 60-10 and 60+4), though some of this may be due to noise and/or missed activations of the hall effect swtiches.
|
|
|
Post by Ben Shaw on Jul 16, 2020 7:34:42 GMT
Tthanks Keith we have just implemented what you have suggested and this has reduces our intervals down to 10! That is a massive improvement i will keep playing with these values to increase the update time from 2 seconds. I have noticed that when opening up the dweet software there is a measure for speed, however no values are displayed here. this is the same with Amps do you have any ideas what could be done to fix this?
thanks, Ben
|
|
|
Post by keduro on Jul 16, 2020 8:04:25 GMT
Morning Ben, First thing to confirm is if the eChook is correctly measuring the speed (based on wheel rotation) and amps. Take a look at the log file created in your phone's download folder and see what values have been logged there. If speed and amps are zero in the log file then need to check the echook board. If speed and amps are non zero in the log file then the problem lies elsewhere - would need to give that some thought. Let us know what you find in the log file, Keith
|
|
|
Post by Rowan on Jul 16, 2020 8:18:48 GMT
Nothing misrepresented there Keith, I'd missed we were still doing it all as integer! That will make a significant improvement.
Changing the short transmit interval will double the resolution of the speed and RPM signals, but it also halves the frequency of all logging which will show as a lot of repeated values in the .csv logfiles. 0.5 seconds is probably still more than fast enough for most logging purposes though!
Are speed and current showing up in the app?
|
|
|
Post by Ben Shaw on Jul 16, 2020 8:27:17 GMT
I am not sure if the app is communicating with the downloads on within the phone as the downloads folder is empty. When i am running the car there is a tick next the the save icon in the top right of the screen. Do i manually need to 'share logged data' with an external source to to see a history of the data or should all of this be automatic?
Also when i start and stop the connection, like it says in the documents that it should, it says the exact amount of data that it has stored in the top left of the screen. Though me it seems like there is data being stored somewhere i just don't know where to find it.
thanks, Ben
|
|
|
Post by Ben Shaw on Jul 16, 2020 8:32:38 GMT
We did at one point have the MPH showing up in the app however this soon stopped, at one point there was a constant reading of 0.6 amps which we put down to wire resistance however it just shows a constant 0 at the moment.
|
|
|
Post by keduro on Jul 16, 2020 10:03:49 GMT
Ben, suggest checking the speed and current sensing on the eChook board. Assuming you have a multimeter ..... Speed: measure the voltage on the terminal on the eChook board to which the wheel hall effect sensor is connected - the wheel RPM input terminal. As you slowly rotate the wheel by hand the voltage should drop from ~5v to nearly zero as each magnet passes the sensor. If it doesn't then check the wiring and sensor positioning relative to the magnets. Current: slightly trickier to test - measure the voltage on pin 1 of the 8 pin op amp which is near the throttle connections on the eChook. Pin 1 is the pin marked with a dot on the IC or the first pin going anti clockwise from the semi circular notch on the IC. The voltage on pin 1 should rise from ~0v with no current flowing to the motor to ~5v with a current of 50A. If you are not seeing this then it could be a problem around the IC but before exploring that it's worth checking the wiring and connections to the current sensor. Fingers crossed this may help isolate the problems. -- Keith
|
|
|
Post by Rowan on Jul 16, 2020 11:13:10 GMT
I am not sure if the app is communicating with the downloads on within the phone as the downloads folder is empty. When i am running the car there is a tick next the the save icon in the top right of the screen. Do i manually need to 'share logged data' with an external source to to see a history of the data or should all of this be automatic? Also when i start and stop the connection, like it says in the documents that it should, it says the exact amount of data that it has stored in the top left of the screen. Though me it seems like there is data being stored somewhere i just don't know where to find it. thanks, Ben We've seen simmilar issues lately with the log file, with other apps as well as ours. It is there, as the file size would show 0 kb if it couldn't find it, however Android seems to be hiding it, or the file manager isn't showing .csv files maybe?? Does it show on windows file explorer if you plug the phone in? If you can't find it on your phone for any reason, going through the share menu should allow you to email/upload/etc it. Regarding current and speed, that seems like the signal either isn't getting to the nano in the first place, or you might have inadvertently disabled the code that reads it in? I took a look at a time based, rather than poll based, calculation for the wheel speed and motor RPM this morning. It turned into quite a big code reorganisation as it really hit me that over time, the changes to that original code have added up and there is a fair bit of redundant code and incorrect comments remaining - sorry about that!! In the years since we originally wrote that code I think my coding style has changed significantly too. So, I have made a new branch of code on github and split the file up into smaller chunks to hopefully make everything easier to find, and more obvious where users can add their own code to the eCHook. It also includes a few improvements that have been found/suggested over time. I have also done a first attempt at the new motor and wheel speed code, and added a toggle to enable it under an 'Experimental' heading in calibration.h. It's currently enabled by default. I'm getting a little ahead of myself sharing it, as I've hardly tested it yet, but hopefully you can see what I'm trying to do. Feel free to give it a shot, just don't be surprised if it doesn't work right now New dev branch of the code is here: github.com/eChook/eChook-Arduino-Nano/tree/dev Any feedback welcome as always
|
|
ben
New Member
Posts: 14
|
Post by ben on Jul 16, 2020 11:37:32 GMT
For the Speed it does seem to do as you say and drop to 0V when it passes a magnet so that seems all good should it be showing up on the phone tho? For the current all I am picking up is 0V. Am I right to put one prong on the ground and one on the 1st connection? Or should I connect one the the current input on the eChook board?
|
|
|
Post by keduro on Jul 16, 2020 11:38:33 GMT
You have been busy Rowan, great work. Can I make a small additional request for an update to the dev branch (yeah, I'm too lazy to make a pull request ... ) - how about changing the speed and current smoothing arrays from int to float to avoid discretizing the calculated averages into thirds and quarters respectively. Thanks! Keith
|
|
|
Post by keduro on Jul 16, 2020 11:48:28 GMT
Ben - if speed sensor is causing voltage to drop to 0 as magnets pass by then yes, it should also be showing up on the phone! Make sure you have appropriate settings in Calibration.h for number of wheel magnets and wheel circumference. For current, yep you're doing the right thing i.e. red prod onto pin 1 of the IC and black prod to ground. If you are seeing a constant 0V that suggests that (a) either a problem with the current sensor wiring / connections, or (b) with the op amp. To eliminate (b), you can use your meter to check the voltages on pin 2 and separately on pin 3. IIRC pin 2 should be a constant voltage ~ 2.5V and pin 3 should increase from ~ 2.5 V as the current to the motor is increased. Just needs a little care when putting prods on ICs not to let them slip and unintentionally short circuit adjacent connnections. Hope this helps ............ Keith
|
|
ben
New Member
Posts: 14
|
Post by ben on Jul 16, 2020 12:24:44 GMT
calibration.h is inline with what we have going on in the car so it should be fine on that front. Ok i believe that (a) would be more likely, however, if the current sensor was incorrectly wired would this reflect on the multimeter by bringing up 0A? i would only imagine that this would stop the information getting to the phone and not alter with the multimeter reading let me know if i am thinking of it the wrong way. I also tested pins 2,3 and 4 all came up as 0V as well :/
Ben
|
|
|
Post by Rowan on Jul 16, 2020 13:54:30 GMT
For the speed reading, it sounds like the Arduino is definitely getting an input. Next test I'd do is flash the Arduino with a fresh copy of the code from github, just to make sure that it's not a change you've made to the code that's stopping it reading. Current sensor wise, pins 2 and 3 should be sitting around 2.5v. Does the current sensor definitely have 5V going to it? keduro - good shout, done. Any other optimisations you've found while I'm at it? I've recently had to dig into the Arduino compiling system for a different project and realised that it was far easier than I'd thought to split the program across multiple files. It makes it far easier to find things I think.
|
|
ben
New Member
Posts: 14
|
Post by ben on Jul 16, 2020 15:14:06 GMT
So i have just took out an old current sensor that was supplied by greenpower we just had a spare laying around to see if that was the problem, we tried it and nothing happened again. we did flip the sensor round in case that was the problem however this only gave us a reading of 2 max and was limited with the results that it was giving us. ie it was either 0 or 2.
also as i am new to this coding, what is the easiest way to save new code, i only ask because when i go to verify some code it gives some errors that it is taking information from other folders around it. im not sure if this is what is happening but i have a few folders with multiple Arduino apps open atm.
Ben
|
|