Hello!
I'm having a hard time making this work.
I'm currently still learning to code in arduino, so bare with me.
I need the board to read four 200psi pressure transducers, check a couple of set goals, and activate one or more out of eight relays according to the preset values.
So lets say if a sensor reads 50 psi in one line( out of 4) and i've pressed a button thats connected to a 100psi preset, it opens the set relays until the pressure is 100psi.
how could I do this? i got stuck at that variables and floating etc, its getting a bit harder so i'd need some help.
thank you very much!
STOP trying to code in computer and lay out exactly what you want in HUMAN.
-jim lee
Post a link to the data sheet of the preasure transducer.
Railroader:
Post a link to the data sheet of the preasure transducer.
https://enimages.ofweek.com/Uploads/20171010/59dc31481d5fc.pdf
Can You copy the data sheet and post? That link is not safe, access is denied.
SPECIFICATION
Supply voltage: 5.0 VDC
Output: 0.5~4.5 VDC
Working current: ≤10 mA
Pressure range: 0~1.2 MPa
Proof Pressure: 2.4 MPa
Burst Pressure: 3.0 MPa
Operating Temp.: 0~85 ℃
Storage Temp.: 0~100 ℃
Measure error: ±1.5 %FSO
Full temp. range error: ±3.5 %FSO
Response: ≤ cycle life: 500,000 pcs
Basically i'm trying to control some air valves trough the relays, that would regulate the air suspension on a car to achieve certain heights.
I'd need 3 preset pressures, and 3 buttons. when one is pressed, the arduino reads the sensor values and opens two valves accordingly..
I've managed to set the pinmodes and test the relays, but i got stuck at the presets part..
Just hardcode a single value to check. Not much point to presets yet as it sounds like you're not reading the pressure sensors.
i'm not acutally. i've tried some sensors from my friend and on his pc. mine are still in transit and should be here soon. But getting the code ready wont hurt.
BLACKDAVID:
But getting the code ready wont hurt.
Be careful with that. It's a common problem to have written all the code in the abstract and then finding that nothing works when you hook it up, leaving yourself with some tricky debugging.
It's usually better to build the system up bit by bit so you can test as you go along.
BLACKDAVID:
SPECIFICATION
Supply voltage: 5.0 VDC
Output: 0.5~4.5 VDC
Working current: ≤10 mA
Pressure range: 0~1.2 MPa
Proof Pressure: 2.4 MPa
Burst Pressure: 3.0 MPa
Operating Temp.: 0~85 ℃
Storage Temp.: 0~100 ℃
Measure error: ±1.5 %FSO
Full temp. range error: ±3.5 %FSO
Response: ≤ cycle life: 500,000 pcs
Using a 5 volt Arduino standard analogRead will work, using an analog pin. Then apply the map-function.
Start simple: Read and show a sensor voltage on the serial monitor.
#define VREF 5.0f
HardwareSerial *serialConsole = (HardwareSerial *)&Serial;
const uint8_t pinSensor = A0;
void setup( void )
{
pinMode( pinSensor, INPUT );
serialConsole->begin(115200);
}//setup
void loop( void )
{
ReadSensor();
}//setup
void ReadSensor( void )
{
static uint32_t
timeLastReading;
uint32_t
timeNow = millis();
if( timeNow - timeLastReading >= 1000ul )
{
timeLastReading = timeNow;
int snsADC = analogRead( A0 );
//assumptions:
// VREF = 5.0V
// 0MPa at 0Vout (0psig)
// 1.2MPa at 4.5Vout
float fMPA = 1.2 * ((VREF * (float)snsADC/1024.0) / 4.5);
float fPSIG = fMPA / 0.00689476;
serialConsole->print( "Pressure ADC: " );
serialConsole->print( snsADC );
serialConsole->print( "\tMPa.......: " );
serialConsole->print( fMPA, 3 );
serialConsole->print( "\tpsig......: " );
serialConsole->print( fPSIG, 3 );
}//if
}//ReadSensor
Hello. I've managed to get someone to help me, and this was the result.
Its giving me an error code " use of undeclared identifier Pro_Function"
void Pro_Function (byte Preset_Value, const byte Pressure_Sensor, const byte Inf_Relay, const byte Def_Relay){
Read_Value = analogRead(Pressure_Sensor);
Pressure_Value = ((250 * Read_Value) / 1023) - 25;
if ((digitalRead(Button_1)) == HIGH){
delay(1000);
digitalWrite(LED, HIGH);
Pro_Function(Front_Value_1, Pressure_1, Inf_Relay_1, Def_Relay_1);
delay(500);
Pro_Function(Front_Value_1, Pressure_2, Inf_Relay_2, Def_Relay_2);
delay(500);
Pro_Function(Back_Value_1, Pressure_3, Inf_Relay_3, Def_Relay_3);
delay(500);
Pro_Function(Back_Value_1, Pressure_4, Inf_Relay_4, Def_Relay_4);
delay(500);
digitalWrite(LED, LOW);
}
if ((digitalRead(Button_2)) == HIGH){
delay(1000);
digitalWrite(LED, HIGH);
Pro_Function(Front_Value_2, Pressure_1, Inf_Relay_1, Def_Relay_1);
delay(500);
Pro_Function(Front_Value_2, Pressure_2, Inf_Relay_2, Def_Relay_2);
delay(500);
Pro_Function(Back_Value_2, Pressure_3, Inf_Relay_3, Def_Relay_3);
delay(500);
Pro_Function(Back_Value_2, Pressure_4, Inf_Relay_4, Def_Relay_4);
delay(500);
digitalWrite(LED, LOW);
}
if ((digitalRead(Button_3)) == HIGH){
delay(1000);
digitalWrite(LED, HIGH);
Pro_Function(Front_Value_3, Pressure_1, Inf_Relay_1, Def_Relay_1);
delay(500);
Pro_Function(Front_Value_3, Pressure_2, Inf_Relay_2, Def_Relay_2);
delay(500);
Pro_Function(Back_Value_3, Pressure_3, Inf_Relay_3, Def_Relay_3);
delay(500);
Pro_Function(Back_Value_3, Pressure_4, Inf_Relay_4, Def_Relay_4);
delay(500);
digitalWrite(LED, LOW);
}
}
It looks like your snippet is using recursion.
Be very,very careful.
Please remember to use code tags when posting code, and remember to post ALL your code.