|
Post by Ben Shaw on Jul 14, 2020 18:37:11 GMT
Hi there, I must give credit to the step by step guide on how to carry out the process of finding code and flashing it to the Arduino from start to finish as i am very new to coding and found it easy. However i was in the process of uploading the code form the Arduino software to the Arduino its self. After i tried to upload it, all of the ten attempts came back saying 'not in sync' and 'program not responding'. I was not too surprised to here this as it mentions on the documentation that errors could occur. Do you have any idea on what could be causing this?
thanks, Ben
|
|
|
Post by keduro on Jul 14, 2020 18:51:10 GMT
Hi Ben, a couple of quick things to check: 1. Do you have the correct Arduino (Nano) and serial port selected in the Arduino IDE? 2. Ensure the bluetooth module is not connected to the eChook when uploading. Despite uploading code many times I still on occasion forget to disconnect the bluetooth module.
|
|
|
Post by keduro on Jul 14, 2020 18:55:19 GMT
And .... As per the write-up ... *As of Arduino IDE v1.8.2 the processor to select is "ATmega328 (Old Bootloader)". Not selecting this will result in AVRDude out of sync errors on uploading. :-)
|
|
|
Post by Ben Shaw on Jul 14, 2020 19:06:30 GMT
Hi, I believe am using the Arduino nano that came with the rest of the pieces and circuit board and have plugged it into the computer via the cable that was provided. I do not have the Bluetooth module connected in fact i only have the Arduino plugged in to the computer as a stand alone unit, should i connect it to the circuit board or was i right to not put them together while uploading? thanks for your rapid reply, Ben
|
|
|
Post by Rowan on Jul 14, 2020 19:09:26 GMT
Hi Ben, If the checks Keduro suggests don't work, try selecting the processor as "ATmega328", the non old bootloader option. I think the Chinese nanos are slowly transitioning to the new bootloader and I've been caught out a couple of times now. If we managed to get a batch of new bootloader arduinos for the latest kits I'll have to update the documentation Did you buy the kit recently? Let us know how you get on! Rowan. _________________________________ Edit, I got sniped! Just the Arduino plugged into the computer should be absolutely fine... Try the new bootloader setting.
|
|
|
Post by Ben Shaw on Jul 14, 2020 19:29:35 GMT
hi Rowan, cheers for the confirmation. i am not sure on the exact date of purchase as it was another mwmber of the team who ordered it however it will of been between 6 to 8 months ago i believe. I changed it to the updated ATmega328 and it seemed to have done the job! there is still however red/orange text for half of the feedback for the upload however it mostly seems to be information rather than errors jut want to check that this is normal. it does look like the new ATmega328 worked tho.
|
|
|
Post by Ben Shaw on Jul 14, 2020 19:51:40 GMT
Hi, once i have completed the steps above is all of the information that is needed down loaded onto the Arduino? do i separately need to down load the 'calibration.h' file or will that be on there from the previous download?
Now that i have successfully downloaded it can i unplug it and plug it back into the computer without loosing the data i have flashed onto it? Also i am just looking ahead in the documentation and it says to use a different power source other than the USB on the Arduino, what will this be?
thanks, Ben
|
|
|
Post by Rowan on Jul 14, 2020 19:56:39 GMT
Ah not a new one then... Odd that you have a newer bootloader version, but I'm glad it seems to have worked!
As long as the IDE says Upload Complete it should have worked regardless of any warnings in the console area, however there shouldn't really be any warnings, it should just read:
Sketch uses 9390 bytes (30%) of program storage space. Maximum is 30720 bytes. Global variables use 480 bytes (23%) of dynamic memory, leaving 1568 bytes for local variables. Maximum is 2048 bytes.
Feel free to paste them here and I'll take a look.
|
|
|
Post by Rowan on Jul 14, 2020 20:05:41 GMT
And sniped again! Hi, once i have completed the steps above is all of the information that is needed down loaded onto the Arduino? do i separately need to down load the 'calibration.h' file or will that be on there from the previous download? Now that i have successfully downloaded it can i unplug it and plug it back into the computer without loosing the data i have flashed onto it? Also i am just looking ahead in the documentation and it says to use a different power source other than the USB on the Arduino, what will this be? thanks, Ben All tabs in the arduino IDE are compiled and flashed onto the arduino when you press upload - no need to do anything extra. The only way to remove the program now is to upload a different one to it - each time it overwrites the last. You can unplug it, you won't loose anything. Once the PCB is built up it will use the greenpower batteries to power the arduino. Any voltage source between 7v and 30v on the 24v input to the eChook board will safely power it. I suspect you're looking at the bluetooth setup step - the reason we advise not having it plugged in via USB for this part is that the computer and the bluetooth module share the same Serial communication pins on the Arduino, and while the arduino is trying to communicate with the bluetooth module, the computer has a habit of throwing in some spurious data and stopping the setup. If you don't have an alternative voltage source handy, plugging the USB into a USB phone charger rather than the computer should work.
|
|
|
Post by Ben Shaw on Jul 14, 2020 20:58:33 GMT
hi, i have carried out all the previous steps and have plugged it into a phone charger into the USB on the Arduino. however, the green LED is flashing which i do not believe is right? i am also having trouble connecting it to the phone. the first time i powered up the board it connected fine and worked fine however it seemed to not work now it has been disconnected and connected again.
thanks, Ben
|
|
|
Post by Rowan on Jul 14, 2020 21:46:55 GMT
Which LED is flashing? Is it the 'L' marked one on the nano or one on the Bluetooth module? The one on the nano should be flashing about 4 times per second.
When you say not work - which bit isn't working? Is it still connecting to the phone, is the app saying disconnected...
|
|
|
Post by Ben Shaw on Jul 15, 2020 7:59:15 GMT
Hi, the LED that was slowly flashing was the green one on the PCB located just under the Arduino. This issue has now been resolved as i have connected it to the the rest of the car and all other terminals have been filled. the issue was with the Bluetooth connection however this has all been resolved.
One other question, i have now got the bluetooth working and information being sent to our phone. is there any way to change the scale resolution? i.E the RPM values go up in 60 as standard, is there any way to make this go up in 5?
thanks, Ben
|
|
|
Post by Rowan on Jul 15, 2020 9:01:01 GMT
Well done, that's rapid progress!
The RPM is a reading is generated by reading how many times the magnets pass the hall effect sensors in 1 second, and then multiplied up by 60 to give RPM, which is where the step size of 60 comes from. You can decrease the sampling rate to increase the resolution (a calculation every 2 seconds will give you a resolution of 30) or you can do more fancy calculations measuring time between magnet pulses to calculate speed which would give a far higher resolution reading, but is more involved on the coding side.
Both solutions require a bit of coding - the method used in the eChook code is the simplest one in an effort to keep the code as understandable as possible for teams new to coding, the lowish resolution being the drawback. 60 gives a step of around 3% at operating speed.
|
|
|
Post by Ben Shaw on Jul 15, 2020 10:01:19 GMT
i see, well we would like to have a more accurate measurement of the RPM. to carry out this process would it incorporate writing new code or editing the current code slightly? i believe i have found the section of the eChook code that i need could you give me some advice to what to change as we have had some testing in changing values however non of this has worked:
float readWheelSpeed() //wheelRPM is updated whenever this is called
{
// First action is to take readings and reset the wheel count so that there are no change to the variables during the calculations or between reading and resetting:
int tempWheelPoll = wheelPoll;
wheelPoll = 0;
unsigned long tempLastWheelPollTime = lastWheelSpeedPollTime;
unsigned long tempWheelPollTime = millis();
lastWheelSpeedPollTime = tempWheelPollTime;
//Wheel RMP has been tacked into this function at a later date, so could do with re-writing really...
//Wheel RMP Calculations:
wheelRPM = (float) tempWheelPoll / (float) CAL_WHEEL_MAGNETS; //gives number of rotations
wheelRPM = wheelRPM / ((float)(tempWheelPollTime - tempLastWheelPollTime) / (float) 60000.0); // /60,000 converts millis to minutes
// All integers in the folowing equation are cast to float so that the value is not converted to an integer at any point reducing accuracy through rounding.
// Next task is to calculate the distance travelled. This is dome by takin the wheel poll, which is the number of magnets that have passed the sensor since the last check
// and dividing it by the number of wheel magnets to give the number of revolutions, then multiply by the circumference to give distance travelled in meters:
float wheelDistanceTravelled = (float) tempWheelPoll / (float) CAL_WHEEL_MAGNETS * (float) CAL_WHEEL_CIRCUMFERENCE;
// Now determine how much time in seconds it took to travel this distance, and divide the distanve by time to get speed in meters per second.
float wheelSpeedMetersPerSecond = wheelDistanceTravelled / ((float)(tempWheelPollTime - tempLastWheelPollTime) / (float)1000.0); // the /1000 converts the milliseconds to seconds
//Next section of code handles the smooting:
speedSmoothingArray[speedSmoothingCount] = wheelSpeedMetersPerSecond; //adds current speed into oldest position in array
speedSmoothingCount ++ ; //incrememnts array position for next reading
if (speedSmoothingCount >= speedSmoothingSetting)
{
speedSmoothingCount = 0; //reset if count exceeds array length
}
wheelSpeedMetersPerSecond = 0; //reset variable ready to sum array
for (int i = 0; i < speedSmoothingSetting; i++)
{
wheelSpeedMetersPerSecond += speedSmoothingArray;
}
wheelSpeedMetersPerSecond = wheelSpeedMetersPerSecond / speedSmoothingSetting; //divide summed figure by array count to get mean value
return (wheelSpeedMetersPerSecond); //return smoothed value
}
float readMotorRPM()
{
// First action is to take copies of the motor poll count and time so that the variables don't change during the calculations.
|
|
|
Post by Rowan on Jul 15, 2020 12:40:57 GMT
It will be a bit more involved than editing values in the current code I'm afraid. The current code is a compromise between update interval, resolution, and simplicity. You can alter the timings (defined by where it's called in loop()) to sacrifice the update interval for improved resolution. You'd need to add a second counter to call the routine less regularly.
Alternatively you can alter the way the interrupts work. Create a couple of new global variables to hold the last seen pulse time, and the latest pulse interval, then every interrupt you can calculate the current millis() - 'last seen time' to give your latest pulse interval, and reset the last seen time to the current millis(). You can now alter the readRPM() function to convert the latest global pulse interval value (i.e. the number of milliseconds that it's taken for one revolution of the motor shaft, assuming one magnet on the motor shaft) into an rpm value. If milliseconds don't give you an adequate resolution you can use the micros() function to measure in microseconds.
There is a note of caution with this approach - the millis()/micros() value doesn't update while the interrupt code is running, so it's generally considered bad practice to use it within an interrupt, however as you only really care about the time at the moment the interrupt is triggered it actually works in your favour here.
I appreciate that's a bit of a deep dive for someone new to coding! If I find some time I'll see if I can get an example up and running.
|
|