Project largely working. Have a 125Khz RFID module on an Arduino Uno, with SD card module and and RTC, all working nicely and passing data via PLX-DAQ to Excel and storing data to SD card.
I need a way of working out when the Uno is connected via PLX-DAQ to USB/serial, or when the Uno is just on battery.
So I thought to set a particular cell on Excel with the PLX-DAQ form macro in VBA to 1 (when connected) or 0 (disconnected) then read that in the Arduino code to determine whether to pass data via serial to excel or pull stored data off SD card.
The cell J4 toggles 0 or 1 according to whether disconnected / connected.
I then use the GET function of PLX-DAQ to read a cell from the Arduino sketch.
To upload the sketch I have to disconnect the connection between the RFID Tx and Arduino Rx or I get an error, which is normal, and if I run the sketch with that wire disconnected GET works fine.
void setup() {
// open serial connection
Serial.begin(9600);
CLOCKSetup();
RFIDSetup();
SDSetup();
Serial.println("CELL,GET,J4");
int iniFlag = Serial.readStringUntil(10).toInt();
Serial.println( (String) "Value of cell iniFlag is: " + iniFlag);
}
gives me this output in PLX-DAQ debug window
Value of cell iniFlag is: 1
=> Sending value '1' from cell 'J4'
CELL,GET,J4
SD card is ready to use.
RTC ready
But if I re-connect the wire from RFID Tx to Uno Rx the same sketch gives me this output
Value of cell iniFlag is: 0
=> Sending value '1' from cell 'J4'
CELL,GET,J4
SD card is ready to use.
RTC ready
There's no data going down the wire to Uno Rx at this stage, I've not scanned anything, and the Rx LED on the Uno doesn't light, so how is it affecting the GET function?
The GET command is handled by this code in PLX-DAQ in the VBA
Case "CELL"
Select Case UCase(DataVal(1))
Case "GET"
'## Get Cell from active sheet or from named sheet
Select Case UCase(DataVal(2))
'## dataval 0 1 2 3 4 5
'## NOTE syntax to be Serial.println("CELL,GET,FROMSHEET,MySheet,C,9");
Case "FROMSHEET"
CommWrite cboPort.Text, Sheets(DataVal(3)).Cells(DataVal(5), DataVal(4)).Value
txtStatus2 = "Getting Cell " & DataVal(4) & DataVal(5) & " from sheet " & DataVal(3)
Call postToDirectDebug("Sending value '" & Sheets(DataVal(3)).Cells(DataVal(5), DataVal(4)).Value & "' from cell '" & DataVal(4) & DataVal(5) & "' of sheet '" & DataVal(3) & "'", DebugLevel.Outgoing)
'## NOTE syntax to be Serial.println("CELL,GET,C9");
Case Else
CommWrite cboPort.Text, WStoUse.Range(DataVal(2)).Value
Call postToDirectDebug("Sending value '" & WStoUse.Range(DataVal(2)).Value & "' from cell '" & DataVal(2) & "'", DebugLevel.Outgoing)
txtStatus2 = "Getting Cell " & DataVal(2)
End Select
Case "SET"
'## Set Cell on active sheet or on named sheet
Select Case UCase(DataVal(2))
'## dataval 0 1 2 3 4 5 6
'## NOTE syntax to be Serial.println("CELL,SET,ONSHEET,MySheet,C,9,Any value");
Case "ONSHEET"
Sheets(DataVal(3)).Cells(DataVal(5), DataVal(4)).Value = ReplaceData(DataVal(6))
txtStatus2 = "Setting Cell " & DataVal(4) & DataVal(5) & " on sheet " & DataVal(3) & " with: " & DataVal(6)
'## NOTE syntax to be Serial.println("CELL,SET,C9,Any value");
Case Else
WStoUse.Range(DataVal(2)).Value = ReplaceData(DataVal(3))
txtStatus2 = "Setting Cell " & DataVal(2) & " with: " & ReplaceData(DataVal(3))
End Select
End Select