|
Post by Rowan on Feb 28, 2020 10:25:23 GMT
Of course Install the library, then in the Arduino IDE go to File>Examples and take a look at the example code to get you started.
|
|
|
Post by littlejo44 on Feb 28, 2020 10:37:33 GMT
Ok...thanks Rowan.....but I'm 12,000 miles from my PC at the moment, so that will have to wait a couple more weeks☹️.. But I didn't realise that serial to bluetooth was encoded in a different way to 'bog standard' serial (technical term).. I thought 'serial' was 'serial', and that it was just the signal levels(like TTL and RS232) that varied...so I can take some time to research a little more into BT...J
|
|
|
Post by Rowan on Feb 28, 2020 12:40:05 GMT
There's no difference in the signal level transmission, but instead of just sending the data as ascii characters in a CSV type format, each value is broken down into an identifier and value and packed into a 5 byte packet. This keeps a very low data rate (in hindsight, far lower than we needed to get it), but has it's drawbacks - such as the data isn't human readable with a standard serial interpreter. More details here: docs.echook.uk/bluetooth-communication
|
|
|
Post by littlejo44 on Feb 28, 2020 12:56:30 GMT
thank you....J
|
|
|
Post by littlejo44 on Mar 1, 2020 4:24:59 GMT
...so just thinking ahead... Going along with your suggestion of 'squirting' out a .csv file....and progressing with caution at this stage....As I only need to transmit, there is a library available for 'Software Serial, Transmit Only' on Github...Can I assume it's ok to 'include' that, and output to (say) Pin 12 (D9)?
|
|
|
Post by Rowan on Mar 2, 2020 8:06:28 GMT
I've never used the transmit only software serial library but I don't see why that wouldn't work. You can also use the normal software serial library and only ever send data out from it.
|
|
|
Post by littlejo44 on Mar 2, 2020 9:24:24 GMT
....ok...but was just thinking about tying up as few pins as poss...but as the pins are available, I guess it would make more sense to use a well tried and tested library...at least in the first instance.. Thanks again..
|
|
|
Post by littlejo44 on Mar 24, 2020 16:51:22 GMT
Hi Rowan...Hope this finds you and yours well!! Back at the sharp end now...Re: the ramp routine you kindly wrote for me: I wonder if you would have any theory on the following... We (Pods..Chipping Sodbury School) now have the echook completed..When checking the board with the echook sketch, plus the throttle ramp, I noticed that (almost) every time the throttle is opened, for a fraction of a second, just as the PWM is reaching 100%, the output drops to zero, before returning to 100%....It is only for a fraction of a second.(.doing a video frame count, I reckon it's about a fifth of a second)...I first noticed it with the onboard PWM LED.. I reloaded the original stand alone ramp sketch you sent me, and the glitch is there also..I just hadn't noticed before.. I think we can get away with the Mark/Space jitter, but the drop to zero would definitely be noticed in the car... I have a few seconds of 'scope video of the glitch if of any use... Sorry to be a pain, but any help would be appreciated.. Thank you. John
....Just an afterthought...The Nano in the echook is not the one I did the original test with, so I wondered if it could be a problem with the new Nano...but I fired up my original nano..and the problem is there also..J
|
|
|
Post by Rowan on Mar 26, 2020 8:23:26 GMT
Hi John, I didn't get an notification for this post - sorry for the slow reply!
The cause doesn't jump out at me reading the code so I'll test it on my eChook later and see what I can find.
Arduinos will be very repeatable - unless one is totally dead or has a dead pin they shouldn't behave differently with the same code
|
|
|
Post by littlejo44 on Mar 26, 2020 9:15:57 GMT
Hi Rowan..no prob on the delay..Time doesn't seem to be a problem for me at the moment😀☹️... I have a few secs of scope vid if that's any help...J
|
|
|
Post by littlejo44 on Apr 9, 2020 15:15:43 GMT
Hi Rowan.. Hope this finds you and yours well in these troubled times.. Despite the lockdown, or maybe, because of it, things have moved on faster than I expected with our new car, and we are nearing the point when the car and the electronics will need to unite..so I'm thinking I need to ignore the slight glitch with the ramp routine and concentrate on attempting to 'squirt' the sensor data to our radio telemetry link.. But...In the interest of time, (and of getting it to work!), I would really appreciate your help here.... Many hours of 'Googling' and reading have proved to my 76 year old brain that my earlier euphoria and confidence at being able to 'make an led flash', were a little premature, and that there is much more to this than I was expecting😩 I should have spent more time learning about bits, bytes, syntax and terminology in general before entering the world of C++! I'm sure, by now, you want me to get to the point! I just need to send the basic Sensor Data, in ASCII format, before any average calculations, via 'SerialSoftware', to our existing telemetry.. I'm thinking that any calibration or calcs can be carried out on the receiving pc.. But...my research has shown that there are (possibly) many ways of doing this and I really have no idea which way to go that's going to give me the most chance of success..Would it be better to send a lot of 'serial write' lines sequentially, or (as we've done with out previous car), combine all the sensor readings into one string?.. What I'm really asking is...could you possibly give me a line of code as a starting point for testing..The Serial Software library is installed and included in the sketch..No handshake is required.. As always, your help would (even more than usually) be appreciated.. John.. Bristol. Happy Easter!!
|
|
|
Post by keduro on Apr 11, 2020 12:38:42 GMT
Hi John, its Keith from the Banchory Academy Greenpower team here. We've done a lot with the eChook and thought I might be able to help you out a bit here - just as Rowan has helped me in the past :-)
I have added a little code to the stock eChookNano code to output a CSV formatted string of values that hopefully is something like you are looking for. This is the output I'm seeing every 3s on my monitor:
0.00,0.10,0.00,21.50,955.22,497.51,6.00,1.92,104.81,50.61,0.00,0
0.00,0.10,0.00,20.00,956.18,498.01,9.00,1.92,101.52,50.75,0.00,0
0.00,0.00,0.00,17.00,956.18,498.01,9.00,1.92,103.12,58.77,0.00,0
0.00,0.16,0.00,14.75,956.18,498.01,9.00,1.92,95.40,61.83,0.00,0
0.00,0.70,0.00,20.75,896.41,448.21,8.67,2.00,71.74,62.00,0.00,0
0.00,1.90,0.00,23.00,956.18,498.01,9.00,1.92,50.61,87.84,0.00,0 (none of the inputs are connected on the nano so some random data there.)
The data fields are in this order:
batteryVoltageTotal, batteryVoltageLower, throttle, current, motorRPM, wheelRPM, wheelSpeed, gearRatio, tempOne, tempTwo, tempThree, brake Here are code additions:
Declare a constant defining how frequently you want to send the data - added after declaration of SHORT_DATA_TRANSMIT_INTERVAL
const unsigned long CSV_DATA_TRANSMIT_INTERVAL = 3000; // transmit interval in ms Declare a variable to track when the csv data was last sent - added after declaration of lastShortDataSendTime
unsigned long lastCSVDataSendTime = 0; Add the code to send the data - added at the end of the loop function
if (millis() - lastCSVDataSendTime > CSV_DATA_TRANSMIT_INTERVAL)
{
lastCSVDataSendTime = millis();
char separator = ',';
Serial.print(batteryVoltageTotal), Serial.write(separator);
Serial.print(batteryVoltageLower), Serial.write(separator);
Serial.print(throttle), Serial.write(separator);
Serial.print(current), Serial.write(separator);
Serial.print(motorRPM), Serial.write(separator);
Serial.print(wheelRPM), Serial.write(separator);
Serial.print(wheelSpeed), Serial.write(separator);
Serial.print(gearRatio), Serial.write(separator);
Serial.print(tempOne), Serial.write(separator);
Serial.print(tempTwo), Serial.write(separator);
Serial.print(tempThree), Serial.write(separator);
Serial.print(brake), Serial.println();
}
I have simply written the data to Serial - you can replace Serial in the last block by SoftwareSerial if you are using that. Alternatively, if you decide to only send data to your existing transmitter and not use the bluetooth connection to the eChook companion app (though I can very much recommend its use!), then you could just use Serial - but then you'll need to comment out the 5 Serial.write lines at the end of the two sendData functions defined towards the end of the code, just before the code to configure the HC-05.
Hope this helps, and good luck!
Keith.
|
|
|
Post by littlejo44 on Apr 11, 2020 13:05:50 GMT
Hi Keith...I (obviously) haven't had a chance yet to properly read your post, but just wanted to get back asap to say 'thank you' for taking the time to try and help an 'old timer' who's more at home with 'valves and variable capacitors' than he is with bits and bytes😩..I'm guessing you can sense my frustration! Thank you so much, and I'll have a close look later.. Kind regards.. John.. Bristol..
|
|
|
Post by keduro on Apr 11, 2020 14:21:59 GMT
One old timer to another :-). In my youth I used to fix up old valve sets that were being discarded in favour of the new fangled transistor radios. Then I got a Philips electronics set one Christmas. BC108s have a lot to answer for :-). -- Keith
|
|
|
Post by keduro on Apr 11, 2020 16:25:27 GMT
John, hi again, just to be absolutely clear, in the post above where I said use SoftwareSerial I should have said use the SoftwareSerial object you declared. So if you declared say SoftwareSerial mySerial(2,3); then you would use mySerial.print and mySerial.write. -- Keith
|
|