I am designning air breather project by using 2 stepper motors (solenoid motor), PIC16F873, Air Sensor.
The two motors will do automatic Excitation, I mean motor1 will control the air in, and motor2 will control the air out proportion to the air sensor feedback (1.8V - 2.6V. I have 7 position which is travel from fully close to fully open. So I defined 7 different valves (valve1(1.6V)to valve7 (2.6V)). I have define vout as 1.6V = valve1. What I mean is that when the AN0 pin voltage = 1.6V, I want the motor to spin a numbers of steps (15 steps in my case)so the solenoid move the rot or mechanism to valve1 position from the 7 and go back to check the AN0 input again. Continue over and over and it can move to any positions until the power is turned off by the user. I use motor to set the valve position proportion the air sensor.
My questions are:
How do I define the label?
This what I put
AD_Pressure equ b'00000001'
output value '1' = off, '0'= on
Valve1 equ 0X01 ;pattern1 b'0001', b'0010', b'0100', .............repeat over and over until reach step 15.
valve2 equ 0x02 ;29 steps
valve7 equ 0x07 ;103 steps
How can I write the program scan the AN0 input and send data to the match pattern the input voltage level match the valve specified and return to scan the AN0 again send.
If you can help me the sample initialization code or let me know I good site on ADC conversion.