Who is here? 1 guest(s)
 Print Thread
Connecting a raspberry pi to artists scope: no readings...
zamunda
Hello greencardigan,

Thanks for your response, I'll try to insulate the probes from the chambers.
I think my mistake was to completely remove the PCB when modifying the fan instead of leaving the capacitors and inductors in place as explained here:
https://www.instructables.com/Arduino-controlled-DIY-Coffee-Roaster/ :
"For my DC fan motor, I modified the PCB to connect this to the TC4+. Essentially, you want to remove the wires, AC capacitor, and bridge rectifier from the PCB, and connect new wires where the output of the bridge rectifier was. This way, we keep the inductors and capacitors around the fan motor, which are useful for filtering out noise. If you remove the PCB entirely and solder wires directly onto the motor terminals, you might have problems with electrical noise making its way down to the TC4+ and messing with your thermocouple readings (or worse)."

But since I already removed it I will try if insulation helps!

Thanks and regards
 
zamunda
Hello,

AC-relay control and probes work fine now, I would like to control the fan as well by means of the Raspberry Pi and Artisan.
Therefore, I bought the L298N, quite cheap (7 euros):

https://www.electronicshub.org/raspberry-pi-l298n-interface-tutorial-control-dc-motor-l298n-raspberry-pi/

I connected the fan, the board and a 12V DC for testing.

This is the script I use (see below)...
From the command line it works quite well (changing speed works as expected) but if I call it from the Event-manager from Artisan, I get mixed results...seems like subsequent commands get mixed so maybe I have to adjust the script, do not know yet...

Any experience with this set-up?

Thanks and regards,


#!/usr/bin/python2.7

import RPi.GPIO as GPIO # Import GPIO module
import time # Import time module
from sys import argv


ENA = 25
IN1 = 24
IN2 = 23

if __name__ == '__main__':
try:
# Initialization
GPIO.setmode(GPIO.BCM) # Use BCM numbering method
GPIO.setup(ENA, GPIO.OUT) # Set the GPIO pin corresponding to ENA to output mode
GPIO.setup(IN1, GPIO.OUT) # Set the GPIO pin corresponding to IN1 to output mode
GPIO.setup(IN2, GPIO.OUT) # Set the GPIO pin corresponding to IN2 to output mode

freq = 500
startspeed = 0
pwm = GPIO.PWM(ENA, freq) # Set the input PWM pulse signal to ENA, the frequency is freq and create a PWM object
pwm.start(startspeed) # Start inputting PWM pulse signal to ENA with the initial duty cycle of speed

speed=int(argv[1])

# Set the motor to forward rotation
GPIO.output(IN1, False) # Set IN1 to 0
GPIO.output(IN2, True) # Set IN2 to 1

pwm.ChangeDutyCycle(speed) # Change the PWM duty cycle
time.sleep(100)

finally:
pwm.stop() # Stop PWM
GPIO.cleanup() # Clean up and release GPIO resources, reset GPIO
 
zamunda
Hello,

Finally, I worked out a script for air-control which works with the Events for Artisan (sliders, buttons), see below...

Script should be called like this fe:
/home/pi/Roaster/Scripts/air-control.py {} [for using with a slider, dynamic value]
/home/pi/Roaster/Scripts/air-control.py 35 [for using with a button, static value]


Regards,


#!/usr/bin/python3

import RPi.GPIO as GPIO # Import GPIO module
import time # Import time module
from sys import argv

ENA = 25
IN1 = 24
IN2 = 23

def get_slidervalue(filepath):
""" Returns the slidervalue as an int, read from the first line of filepath """
with open(filepath) as f:
first_line = f.readline().strip()

return int(first_line)

if __name__ == '__main__':
try:
# read the slider value from argv
speed = int(argv[1])
sliderfilepath = "/home/pi/Roaster/Scripts/airvalue.txt"
# write the slider value to the file and close file
sliderfile = open(sliderfilepath, "w")
sliderfile.write(str(speed))
sliderfile.close()

# Initialization
GPIO.setmode(GPIO.BCM) # Use BCM numbering method
GPIO.setup(ENA, GPIO.OUT) # Set the GPIO pin corresponding to ENA to output mode
GPIO.setup(IN1, GPIO.OUT) # Set the GPIO pin corresponding to IN1 to output mode
GPIO.setup(IN2, GPIO.OUT) # Set the GPIO pin corresponding to IN2 to output mode

freq = 500
startspeed = 0
pwm = GPIO.PWM(ENA, freq) # Set the input PWM pulse signal to ENA, the frequency is freq and create a PWM object
pwm.start(startspeed) # Start inputting PWM pulse signal to ENA with the initial duty cycle of speed

# Set the motor to forward rotation, switch IN1 and IN2 to backward rotation if needed
GPIO.output(IN1, False) # Set IN1 to 0
GPIO.output(IN2, True) # Set IN2 to 1

# while this file has the latest cycle value
latestSpeed = True
while latestSpeed:
# check if this is not the newest process
newestSpeed = get_slidervalue(sliderfilepath)
if newestSpeed != speed:
latestSpeed = False
break
# set fan to desired speed
pwm.ChangeDutyCycle(speed) # Change the PWM duty cycle

finally:
pwm.stop() # Stop PWM
GPIO.cleanup() # Clean up and release GPIO resources, reset GPIO
 
Jump to Forum: