Example project for the Rioux Chem control box
Rioux Chem Control Box
This is the example project for the Rioux Chem Control Box. I have posted some youtube videos to guide you through the hardware and software:
Rioux Chem Control Box - Hardware
http://www.youtube.com/watch?v=MoZ92GRYa4s
Rioux Chem Control Box - Software - Part I
http://www.youtube.com/watch?v=_MwaTLL4dyA==
Rioux Chem Control Box - Software - Part II
http://www.youtube.com/watch?v=j_P89izfgoQ
Revision 7:de452fceafc1, committed 2021-09-20
- Comitter:
- wavenumber
- Date:
- Mon Sep 20 01:32:52 2021 +0000
- Parent:
- 6:6a870e1e52c1
- Child:
- 8:0cf1573051e8
- Commit message:
- Returning data back from the Pump. Reverting to 82 ohm resistor for 4-20
Changed in this revision
--- a/DRIVERS/CHEM_BOX_COMMON.cpp Sun Sep 12 20:53:43 2021 +0000
+++ b/DRIVERS/CHEM_BOX_COMMON.cpp Mon Sep 20 01:32:52 2021 +0000
@@ -369,7 +369,7 @@
if(Channel > 1)
Channel = 1;
- return (((float)(ReadRawADC(Channel + 7)) /4095.0) * 5.0) / 240;
+ return (((float)(ReadRawADC(Channel + 7)) /4095.0) * 5.0) / 82;
}
@@ -633,14 +633,87 @@
TerminalEcho = 0;
}
+uint8_t RS232_Buff[2][256];
+
+uint32_t RS232_Idx[2];
+
+
+void ResetRS232_Response(uint32_t Channel)
+{
+ if(Channel == 0)
+ {
+ RS232_Idx[0] = 0;
+ }
+ else
+ {
+ RS232_Idx[1] = 0;
+ }
+}
void TerminalCmd_P0(char *arg)
{
+ ResetRS232_Response(0);
RS232_0.printf("%s\r",arg);
}
+
+void ProcessRS232()
+{
+ uint8_t Val;
+
+ while(RS232_0.readable())
+ {
+ Val = RS232_0.getc();
+
+ if(Val == 0x03)
+ {
+
+ if(RS232_Idx[0]>0)
+ {
+ RS232_Buff[0][RS232_Idx[0]++] = 0;
+ PC.printf("P:0:%s\r\n",&RS232_Buff[0][0]);
+ ResetRS232_Response(0);
+ break;
+ }
+ }
+ else
+ {
+ if((Val>0x020) && (Val<0x7F) && (RS232_Idx[0]<(sizeof(RS232_Buff)-1)))
+ {
+ RS232_Buff[0][RS232_Idx[0]++] = Val;
+ }
+ }
+ }
+
+
+ while(RS232_1.readable())
+ {
+ Val = RS232_1.getc();
+
+ if(Val == 0x03)
+ {
+ if(RS232_Idx[1]>0)
+ {
+ RS232_Buff[1][RS232_Idx[1]++] = 0;
+ PC.printf("P:1:%s\r\n",&RS232_Buff[1][0]);
+ ResetRS232_Response(1);
+ break;
+ }
+ }
+ else
+ {
+ if((Val>0x020) && (Val <0x7F) && (RS232_Idx[1]<(sizeof(RS232_Buff)-1)))
+ {
+ RS232_Buff[1][RS232_Idx[1]++] = Val;
+ }
+ }
+ }
+}
+
+
void TerminalCmd_P1(char *arg)
{
+ ResetRS232_Response(1);
RS232_1.printf("%s\r",arg);
}
--- a/DRIVERS/CHEM_BOX_INTERFACE.h Sun Sep 12 20:53:43 2021 +0000 +++ b/DRIVERS/CHEM_BOX_INTERFACE.h Mon Sep 20 01:32:52 2021 +0000 @@ -162,5 +162,7 @@ //This is the serial object for the USB connection. Used by the Serial terminal extern MODSERIAL PC; +//Process incomings lines from the PUmp +void ProcessRS232(); #endif \ No newline at end of file
--- a/main.cpp Sun Sep 12 20:53:43 2021 +0000
+++ b/main.cpp Mon Sep 20 01:32:52 2021 +0000
@@ -51,6 +51,8 @@
//Call this often if you want the USB interface/Terminal
ProcessTerminal();
+ //Call this process incoming lines from the pump
+ ProcessRS232();
/*
Eli Hughes

