REMOTING SIX SENSORS ON ONE TWISTED PAIR - PART 4

Post any questions you may have about our current range of USB data loggers
Post Reply
Glovisol
Advanced User
Advanced User
Posts: 0
Joined: Sat May 11, 2013 10:03 am
Location: San Marzano Oliveto, Asti, Italy

REMOTING SIX SENSORS ON ONE TWISTED PAIR - PART 4

Post by Glovisol »

System detail (Medium).jpg
4. ARDUINO DEMO SOFTWARE

IMPORTANT! The demo software to be presented has been developed for the (now old) Arduino 1, whose biggest limit in this project is the reduced output resolution of 8 bits. Even if not yet tested, the same software, probably with a few small modifications, will be able to drive the new Arduino M0 or the newest Arduino M0 PRO. Apart from the significantly bigger operating speed (48 Mhz) the new micros (with a programmable PWM resolution) will guarantee an overall System resolution of up to12 bit, e.g. 2,500/4095 = 0.61 mV. Amended as of 24/2/16: for the time being no proper technical documentation has been made available for Arduino M0 and M0 PRO and judging by the state of confusion reigning, I expect to be able to move to these new devices not before 8/9 months.

4.1 Direct connection
It is possible to test the software without the RS485 Modems, by simply connecting Master & Slave, as shown in the enclosed schematic. This interconnection is also useful when trouble in the Modems is suspected.

4.2 Master & Slave sketches
Unfortunately the original Arduino files are not accepted by the Pico Site and therefore cannot be downloaded. I have copied and downloaded the contents into WORD files. Please carefully copy the text of each file and paste it into an Arduino blank file: it will compile and upload with no trouble. If it does not compile, most probably one or more inverted commas (“”) will have become garbled in the transfer from WORD to Arduino IDE and will have to be manually corrected.

In the sketches almost every step has been commented. However, if anybody needs a logic diagram, will be happy to deliver.

4.3 Quick System testing
Before compiling/uploading the sketches, open the Arduino folder and make sure you have the Software Serial library in the libraries folder. I advise the following steps.

a) Connect the Arduinos with the direct connection (no Modems).
b) Provide the + 2.5 V EXTERNAL REFERENCE voltage with an external PSU: precision is not necessary at this stage.
c) Use two PC's driving the Arduinos thru their USB buses.
d) Upload the sketches and, if there are no problems in compiling/uploading, the System will start working at once, as described in previous Part 2.
e) Problems in compiling/uploading will only depend on errors in transferring the sketch from Word format to Arduino format, so every software entry must be carefully checked against the text in Word format.
f) If nothing is connected to Slave's A0 input, the PWM pin 3 on the Master will be at zero potential (no PWM). Now connect a 10 K multiturn between ground and the +2.5 V reference PSU with the centre pin to Slave's A0 and pin 3 of the Master will become alive.

Once all above done and working, you can proceed with Modem installation, which will be covered next.
Attachments
sketch_MASTER_485_DrDAQ_DEMO_2.doc
MASTER UNIT SKETCH
(34.5 KiB) Downloaded 417 times
Direct interconnection.JPG
Modems & lowpass (Medium).jpg
sketch_SLAVE_485_DrDAQ_DEMO_2.doc
SLAVE UNIT SKETCH
(29.5 KiB) Downloaded 433 times
Last edited by Glovisol on Wed Feb 24, 2016 11:03 am, edited 2 times in total.

Glovisol
Advanced User
Advanced User
Posts: 0
Joined: Sat May 11, 2013 10:03 am
Location: San Marzano Oliveto, Asti, Italy

Re: REMOTING SIX SENSORS ON ONE TWISTED PAIR - PART 4

Post by Glovisol »

ERRATA CORRIGE

There is a small, but very significant mistake in the Slave sketch of the previous post.

//OPERATION
void loop(void) //With this special command the Slave iterations are counted.
{
digitalWrite(SSerialTxControl, RS485Receive); //Sets Pin 2 LOW for receive.
if (RS485Serial.available()>1) //Checks that data is available on RS485 Serial Port.
{
byteRS485 = RS485Serial.read(); //Reads the Sync Byte.
if(byteRS485 = = 123) //Checks the incoming Sync Byte from Master and carries on if O.K.
{
sensorValue_0 = analogRead(analogInPin0); //Reads the SensorValue_0 from pin A0 in Digital 10 Bit format.


In the original sketch, red line, one "=" sign got lost: please correct as shown.

Apologies,

glovisol

Post Reply