11/24/2023 0 Comments Arduino pwm buck converter![]() ![]() I'm using the & operators in my IF statement to define ranges for each sensor, and will expand upon this once it is working as desired. My simulator has sliders that allow for 0-1023 values on the analog pins, and it shows the 0-255 output on the digital pins. When I ran this as a single input, it worked as designed. When both are at 1023, the PWM is 0, which is a desired setting. Adding the dual analogreads and10ms delays seemed to help with this. However the PWM output flickers when I vary the input depending upon what each sensor is reading (for example, if the ECT is in the 0 range and the ACP is in the 200 range, it flickers from 200 to 000. If I can get the dual inputs sorted, then I can move on to learning about conditional text so I can properly vary the PWM based upon the input value.Īfter doing some more reading, I have written a sketch that should allow for two inputs and two fan speeds per input as well as an off setting for the fan. When I move the voltage slider for ECT, it looks like the PWM value is pulsing. ![]() When I do that, the only sensor read on the simulator is ACP. Val1 = analogRead(acpPin) // read the ACP input pinĪnalogWrite(pwmPin, val1 / 4) // analogRead values go from 0 to 1023, analogWrite values from 0 to 255 I then tried to add in the second sensor via a Val1 setting: int ectPin = A0 //analog input 0 Engine Coolant Temp or ECT Val0 = analogRead(ectPin) // read the ECT input pinĪnalogWrite(pwmPin, val0 / 4) // analogRead values go from 0 to 1023, analogWrite values from 0 to 255Īs written, this allows me to vary the A0 value (val0) and see a corresponding change on the PWM output. PinMode(pwmPin, OUTPUT) // sets the PWM pin as output Int pwmPin = 5 // PWM output connected to digital pin 5 Int val1 = 0 // variable to store the value read of a1 Int val0 = 0 // variable to store the value read of a0 Int acpPin = A1 // analog input 1 AC Pressure or ACP Int ectPin = A0 //analog input 0 Engine Coolant Temp or ECT Here is what I'm starting with: //This file is meant to accept input from two automotive sensors and then convert their data to a PWM signal to operate a cooling fan as needed, based upon either temperature or pressure. I'm trying to learn on implementing this, but it is slow going. I plan on collecting AC pressure data vs volts via my scanner while the engine is running so I can make a table for it as well. I did find a resistance table for it, so I have a good data source for setting up the values I'll need at some point. To complicate matters some more, while the AC pressure sensor is a 3-wire 0-5V unit, the engine coolant sensor is a 2-wire resistance-based unit. This means I need (if possible) the Arduino to have dual analog inputs with the single PWM output. However my needs have changed- what I need to do now is bypass the engine computer's fan control entirely. The file update cured the issue, the sketch runs OK now.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |