TCCR0B = TCCR0B & B11111000 | B00000010;
from nanpy import ArduinoApi, SerialManagerfrom time import sleep#Declaration of pins and variables#This section concerns inputs and ouputs from ultra-switchy boisolenoidPin1 = 5solenoidPin2 = 6usrInput = 0valvenumber = 1try: connection = SerialManager(device = '/dev/tty.usbmodem14101') a = ArduinoApi(connection = connection)except: print("Failed to connect to CRIOLE")#Setting up solenoid outputsa.pinMode(solenoidPin1, a.OUTPUT)a.pinMode(solenoidPin2, a.OUTPUT)#Main loopwhile True: valvenumber = input("Which valve pin would you like to change? (5 or 6): ") usrInput = input("Enter a value for Valve Pin " + valvenumber + " between 0-255: ") a.analogWrite(valvenumber, usrInput) print(valvenumber + " , " + usrInput)
However, if not do you think that an analog pin would work better in this case?
Analog pins are for analog input only, no analog output. PWM is the closest to an analog output that you can get. The common Uno and Mega series don't have a DAC.The default PWM frequency of an Arduino is about 480 Hz or 960 Hz depending on the PWM pin used.I think the circuit is using the solenoid coil to smooth out the current (it's an inductor after all). But no flyback diode??
You wrote, and I quote:"To do this, we are planning to use proportional solenoid valves and pressure transducers to measure the system pressure in real time. ".May I suggest you already have a problem. If your end product is "extrusion", then you need to measure the speed of the syringe plunger movement. The air pressure just needs to be adjusted to maintain the desired plunger speed. The actual air pressure is irrelevant.Paul
I see what you're saying, but wouldn't the backed up air pressure in the system affect the extrusion rate?Or do you think the pressure change from when the syringe is full to when its empty would be negligible? I would like to measure the speed of the plunger, but I'm not sure how to do it accurately. Maybe with some sensor or camera?Thanks for the advice,Frank