Search Project: *:*

 
<< < 1 .. 58 59 60 61 62 .. 3636 > >> (Page 60 of 3636)

home Discussion Relay Pi-Plate home (Discussion)
Forum for home comments
Last updated: 2019-11-30

code Discussion Relay Pi-Plate code (Discussion)
Forum for code comments
Last updated: 2019-11-30

tickets Discussion Relay Pi-Plate tickets (Discussion)
Forum for tickets comments
Last updated: 2019-11-30

wiki Discussion Relay Pi-Plate wiki (Discussion)
Forum for wiki comments
Last updated: 2019-11-30

Home briangehrke wiki (WikiPage)
This is the personal project of briangehrke. This project is created automatically during user registration as an easy place to store personal data that doesn't need its own project such as cloned repositories.
Last updated: 2019-11-30

Home (version 1) discussion briangehrke wiki (Thread)
Home (version 1) discussion
Last updated: 2020-01-03

(no subject) briangehrke wiki (Thread)
Last updated: 2019-11-30

blog Discussion briangehrke blog (Discussion)
Forum for blog comments
Last updated: 2019-11-30

wiki Discussion briangehrke wiki (Discussion)
Forum for wiki comments
Last updated: 2019-11-30

Pi-Plate Python Code To SPI Relay Pi-Plate home (WikiPage)
Project Members: BG_Automation (admin) Background I purchased this Relay PI-Plate and it works very well using python. I though I could expand its uses with codesys and make my own driver. I emailed the support and asked for a C library or if they would explain more about how the driver works. They said no they would not help, develop a C library. The python library was the only thing they would supply, but I was welcome to develop my own library based on their python library. I read how to develop a SPI bus device driver on the forge and though I would give it a shot. Below is what I discovered so far. My main goal would be to add a device under the SPI bus master and map each relay to a boolean value. Also the relay. I would like to get also poll all the board information and map that to a variable. Pages: [Pi-Plate Information] [Relay Plate Python Code] [Convert to Python to Codesys]
Last updated: 2019-12-07

Home Relay Pi-Plate wiki (WikiPage)
Background I purchased this Relay PI-Plate and it works very well using python. I though i could expand its uses with codesys and make my own driver. I emailed the support and asked for a C library or if they would explain more about how the driver works. They said no, they would not help. The python libaray was the only thing they would supply, but I was welcome to develop my own library based on their python library. I read how to develop a SPI bus device driver on the forge and though I would give it a shot. Below is what I discovered so far. My main goal would be to add a device under the SPI bus master and map each relay to a boolean value. Also the relay. I would like to get also poll all the board information and map that to a variable. Product Data https://pi-plates.com/relayr1/ Python Code https://forge.codesys.com/drv/relay-pi-plate/wiki/Pi-Plate%20Code%20to%20Convert%20To%20SPI/ User Guide https://pi-plates.com/relayplate-users-guide/ Command Reference https://pi-plates.com/downloads/RELAYplateQuickReferenceGuide.pdf Data Relay Plate Address Relay Number Relay State Relay Functions Turn Relay On Turn Relay Off Toggle Relay Relay All (Byte) Return Relay State LED Functions Set LED Clear LED Toggle LED System Functions Get Firmware Version Reset Address Range of boards 0 to 7 Relay Range 1 to 7 GPIO Used, I will write out what they are for when I find out. The following pins are dedicated to Pi-Plates and cannot be shared: Pin 22 / GPIO 25 Pin 26 / GPIO 7 Pin 16 / GPIO 23 Pin 15 / GPIO 22 The following pins are used for SPI communication and can be used by other SPI-enabled devices selected by CE0. They cannot be used for GPIO: Pin 19 / GPIO 10 Pin 21 / GPIO 9 Pin 23 / GPIO 11 The following pin may be used by Pi-Plates if their features are enabled: Pin 12 / GPIO 18 The following pins are reserved for future expansion: Pin 16 / GPIO 23 Pin 18 / GPIO 24
Last updated: 2019-12-06

Relay Plate Python Code Relay Pi-Plate wiki (WikiPage)
#**********************Relay import os import sys file_dir = os.path.dirname(__file__) sys.path.append(file_dir) from BASE import * #==============================================================================# # RELAY Functions # #==============================================================================# def relayON(addr,relay): VerifyADDR(addr) assert ((relay>=1) and (relay<=2)),"Relay number out of range. Must be between 1 and 2" relay -= 1 ppCMD(addr,0x10,relay,0,0) def relayOFF(addr,relay): VerifyADDR(addr) assert ((relay>=1) and (relay<=2)),"Relay number out of range. Must be between 1 and 2" relay -= 1 ppCMD(addr,0x11,relay,0,0) def relayTOGGLE(addr,relay): VerifyADDR(addr) assert ((relay>=1) and (relay<=2)),"Relay number out of range. Must be between 1 and 2" relay -= 1 ppCMD(addr,0x12,relay,0,0) def relayALL(addr,relays): VerifyADDR(addr) assert ((relays>=0) and (relays<=3)),"Argument out of range. Must be between 0 and 3" ppCMD(addr,0x13,relays,0,0) def relaySTATE(addr,relay): VerifyADDR(addr) assert ((relay>=1) and (relay<=2)),"Relay number out of range. Must be between 1 and 2" relay -= 1 resp=ppCMD(addr,0x14,relay,0,1) return resp[0] #***************************BASE import spidev import RPi.GPIO as GPIO baseADDR=48 ppNAME='TINKERplate' GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) baseADDR=48 MAXADDR=8 ppFRAME = 25 ppINT = 22 ppACK = 23 GPIO.setup(ppFRAME,GPIO.OUT) GPIO.output(ppFRAME,False) #Initialize FRAME signal time.sleep(.001) #pause to let Pi-Plate reset SPI HW if necessary GPIO.setup(ppINT, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(ppACK, GPIO.IN, pull_up_down=GPIO.PUD_UP) try: spi = spidev.SpiDev() spi.open(0,1) except: print("Did you enable the SPI hardware interface on your Raspberry Pi?") print("Go to https://pi-plates.com/getting_started/ and learn how.") DataGood=False platesPresent = list(range(8)) def VerifyADDR(addr): assert ((addr>=0) and (addr<MAXADDR)),ppNAME+" address out of range" addr_str=str(addr) assert (platesPresent[addr]==1),"No "+ppNAME+" found at address "+addr_str def VerifyCHAN(chan): assert ((chan>=1) and (chan<9)),"Invalid channel number - must be between 1 and 8" def ppCMD(addr,cmd,param1,param2,bytes2return): global baseADDR global DataGood DataGood=True arg = list(range(4)) resp = [] arg[0]=addr+baseADDR; arg[1]=cmd; arg[2]=param1; arg[3]=param2; DataGood=True t0=time.time() wait=True while(wait): if (GPIO.input(ppACK)==1): wait=False if ((time.time()-t0)>0.05): #timeout wait=False DataGood=False if (DataGood==True): ppFRAME = 25 GPIO.output(ppFRAME,True) null=spi.xfer(arg,500000,5) #DataGood=True t0=time.time() wait=True while(wait): if (GPIO.input(ppACK)!=1): wait=False if ((time.time()-t0)>0.05): #timeout wait=False DataGood=False if (bytes2return>0) and DataGood: t0=time.time() wait=True while(wait): if (GPIO.input(ppACK)!=1): wait=False if ((time.time()-t0)>0.08): #timeout wait=False DataGood=False if (DataGood==True): for i in range(0,bytes2return+1): dummy=spi.xfer([00],500000,5) resp.append(dummy[0]) csum=0; for i in range(0,bytes2return): csum+=resp[i] if ((~resp[bytes2return]& 0xFF) != (csum & 0xFF)): DataGood=False GPIO.output(ppFRAME,False) return resp def getID(addr): global baseADDR VerifyADDR(addr) addr=addr+baseADDR id="" arg = list(range(4)) resp = [] arg[0]=addr; arg[1]=0x1; arg[2]=0; arg[3]=0; DataGood=True t0=time.time() wait=True while(wait): if (GPIO.input(ppACK)==1): wait=False if ((time.time()-t0)>0.05): #timeout wait=False DataGood=False if (DataGood==True): ppFRAME = 25 GPIO.output(ppFRAME,True) null=spi.xfer(arg,500000,50) #DataGood=True t0=time.time() wait=True while(wait): if (GPIO.input(ppACK)!=1): wait=False if ((time.time()-t0)>0.05): #timeout wait=False DataGood=False if (DataGood==True): count=0 csum=0 go=True while (go): dummy=spi.xfer([00],500000,40) if (dummy[0] != 0): num = dummy[0] csum += num id = id + chr(num) count += 1 else: dummy=spi.xfer([00],500000,40) checkSum=dummy[0] go=False if (count>25): go=False DataGood=False #print checkSum, ~checkSum & 0xFF, csum & 0xFF if ((~checkSum & 0xFF) != (csum & 0xFF)): DataGood=False GPIO.output(ppFRAME,False) return id def getADDR(addr): global baseADDR resp=ppCMD(addr,0x00,0,0,1) #print resp, DataGood; if (DataGood): return resp[0]-baseADDR else: return 8 def quietPoll(): global platesPresent ppFoundCount=0 for i in range (0,8): platesPresent[i]=0 rtn = getADDR(i) if (rtn==i): platesPresent[i]=1 ppFoundCount += 1 def RESET(addr): VerifyADDR(addr) resp=ppCMD(addr,0x0F,0,0,0) time.sleep(.10)
Last updated: 2019-12-07

Convert to Python to Codesys Relay Pi-Plate wiki (WikiPage)
Draft The PI-Plate has manufactures devices that can be used with the Raspiberry-PI. The objective of this project would not stop at just the relay plate, but also incorporate other Pi-Plate devices. The Device driver will be a child of the SPI master and have 7 slots for Pi-Plate devices. Pi-Plates Data Acquisition Plate with Generator Capabilities Data Acquisition Plate Tinker Plate, Mix of Data Acquisition and inputs Relay Control Temperature Measurement Motion Control https://pi-plates.com/pi-plates-catalog/ The relay plate has 7 relays on the plate. Looks like it is because of size and cost constraints. Stacking the plates will allow for 49 relays. Which is plenty for most projects and there is always the possibility of stringing together multiple Rasp-PIs via ethercat. Each relay will be mapped to a variable so true will be on and false will be off. RELAY Control Functions relayON(addr,relay) - turns on (closes) the specified relay relayOFF(addr,relay) - turns off (opens) the specified relay relayTOGGLE(addr,relay) - "toggles" state of specified relay. If relay is on, this command will turn it off. If relay is off, this command will turn it on. Use this command to blink a lamp off and on. relayALL(addr,value) - used to control the state of all relays with a single command. "value" is a 7 bit number with each bit corresponding to a relay. Bit 0 is relay 1, bit 1 is relay 2, and so on. To turn all the relays on at once, use the number 127 for the value. * relaySTATE(addr) - Returns a 7-bit number with the current state of each relay. Bit 0 is relay 1, bit 1 is relay 2, and so on. A "1" in a bit position means that the relay is on and zero means that it's off. LED Control Functions setLED(addr) - turn on the LED clrLED(addr) - turn off the LED * toggleLED(addr) - if LED is on, turn off. If LED is off, turn on. System Level Functions getID(addr) - return Pi-Plate descriptor string getFWrev(addr) - return FW revision in byte format getHWrev(addr) - return HW revision in byte format getPMrev() - returns revision of python module getADDR(addr) - return address of pi-plate. Used for polling available boards at power up. RESET(addr) - set RELAYplate to power-on state. Turns all relays off. ** I am going to focus on RelayAll setLED clrLED getFWrev getHWrev RESET Python Code def getHWrev(addr): global RELAYbaseADDR VerifyADDR(addr) resp=ppCMDr(addr,0x02,0,0,1) rev = resp[0] whole=float(rev>>4) point = float(rev&0x0F) return whole+point/10.0 def getFWrev(addr): global RELAYbaseADDR VerifyADDR(addr) resp=ppCMDr(addr,0x03,0,0,1) rev = resp[0] whole=float(rev>>4) point = float(rev&0x0F) return whole+point/10.0 def relayALL(addr,relays): VerifyADDR(addr) assert ((relays>=0) and (relays<=127)),"Argument out of range. Must be between 0 and 127" ppCMDr(addr,0x13,relays,0,0) def ppCMDr(addr,cmd,param1,param2,bytes2return): global RELAYbaseADDR arg = list(range(4)) resp = [] arg[0]=addr+RELAYbaseADDR; arg[1]=cmd; arg[2]=param1; arg[3]=param2; GPIO.output(ppFRAME,True) null=spi.xfer(arg,300000,60) #null = spi.writebytes(arg) if bytes2return>0: time.sleep(.0001) for i in range(0,bytes2return): dummy=spi.xfer([00],500000,20) resp.append(dummy[0]) time.sleep(.001) GPIO.output(ppFRAME,False) time.sleep(.001) return resp **Codesys Code:** FB_Relay_Plate //Globals Hardware_Version : BYTE; Firmware_Version : BYTE; Relay_Plate_Address : BYTE; //0 to 7 Assigned by slot address? Relay_States : BYTE; //0 to 127, Bit 0 = Relay 0, Bit 7 = Relay 7 Led_State : BOOL; //True = On, False = Off Previous_State : BYTE; End VAR CONSTANT Relay_Base_Address : BYTE := 24; Frame_GPIO : BYTE := 25; PPINT : BYTE := 22; END_VAR Intialize Method Set_Address Method Get_Hardware_Version : BYTE; Method Get_Firmware_Version : BYTE; Cyclic Calls METHOD Set_IO VAR Previous_Relay_State : BOOL; Previous_LED_State : BOOL; Send_Data : BOOL; CommandData : ARRAY [0..6] OF BYTE; END_VAR Write_Data(Data:=CommandData,Execute:=Send_Data, Data_Sent => DataSent); Case of iState Set_Relays: IF Previous_State <> Relay_States Send_Data := True; (*Format: ppCMDr(addr,0x13,relays,0,0) arg[0]=addr+RELAYbaseADDR; arg[1]=cmd; arg[2]=param1; arg[3]=param2; null=spi.xfer(arg,300000,60) 300000 = 0x93E0; 60 = 0x3C; *) CommandData[0] := Relay_Base_Address + Relay_Plate_Address; CommandData[1] := 16#0x13; //COMMAND FOR ALL RELAYS CommandData[2] := Relay_States; //CURRENT RELAY STATE MAP CommandData[3] := 16#0x04; //Don't know what the rest does CommandData[4] := 16#0x93; CommandData[5] := 16#0xE0; CommandData[6] := 16#0x3C; If DataSent Then Relays_Set := true; Send_Data := False; Previous_State := Relay_States; End_IF Else Relays_Set := true; End_IF If Relays_Set = True Then Send_Data := False; Previous_State := Relay_States; iState := Set_Leds; End_IF Set_Leds : Function Write_Data VARINPUT bExecute : BOOL; Data_Command : ARRAY [0..6] OF BYTE; END_VAR VAR iStep : INT; VAR_END VAR OUTPUT Data_Sent : BOOL; VAR_END IF bExecute Then //Set frame GPIO //On_Output //Not sure how to do this yet //Send 1 byte at a time senddata(Data:= Data_Command[iStep]); //move to the next byte iStep := iStep + 1; //if last byte then reset and indicate last data sent if iStep = 7 Then iStep := 0; Data_Sent := True //Turn the output off //Not sure how to do this yet. End_IF Else //Reset Function if not executing iStep := 0; Data_Sent := False; End_If; Method sendData : BOOL; VAR_INPUT DATA : BYTE; END_VAR VAR abyTxBuffer: ARRAY [0..2] OF BYTE; abyRxBuffer: ARRAY [0..2] OF BYTE; END_VAR abyTxBuffer[0] := DATA; //SPI_WRITE_CMD; abyTxBuffer[1] := byPort; abyTxBuffer[2] := byValue; Write_Data := transfer(pabyTxBuffer:=ADR(abyTxBuffer) , pabyRxBuffer:=ADR(abyRxBuffer) , udiLen:=3 , uiDelayus:=5 ); IF NOT Write_Data THEN _iState := 1000; END_IF
Last updated: 2019-12-07

Pi-Plate Information Relay Pi-Plate wiki (WikiPage)
Product Data https://pi-plates.com/relayr1/ Python Code https://forge.codesys.com/drv/relay-pi-plate/wiki/Pi-Plate%20Code%20to%20Convert%20To%20SPI/ User Guide https://pi-plates.com/relayplate-users-guide/ Command Reference https://pi-plates.com/downloads/RELAYplateQuickReferenceGuide.pdf Data Relay Plate Address Relay Number Relay State Relay Functions Turn Relay On Turn Relay Off Toggle Relay Relay All (Byte) Return Relay State LED Functions Set LED Clear LED Toggle LED System Functions Get Firmware Version Reset Address Range of boards 0 to 7 Relay Range 1 to 7 GPIO Used, I will write out what they are for when I find out. The following pins are dedicated to Pi-Plates and cannot be shared: Pin 22 / GPIO 25 Pin 26 / GPIO 7 Pin 16 / GPIO 23 Pin 15 / GPIO 22 The following pins are used for SPI communication and can be used by other SPI-enabled devices selected by CE0. They cannot be used for GPIO: Pin 19 / GPIO 10 Pin 21 / GPIO 9 Pin 23 / GPIO 11 The following pin may be used by Pi-Plates if their features are enabled: Pin 12 / GPIO 18 The following pins are reserved for future expansion: Pin 16 / GPIO 23 Pin 18 / GPIO 24
Last updated: 2020-04-28

Home (version 2) discussion Relay Pi-Plate wiki (Thread)
Home (version 2) discussion
Last updated: 2019-12-29

Pi-Plate Python Code To SPI (version 9) discussion Relay Pi-Plate home (Thread)
Pi-Plate Python Code To SPI (version 9) discussion
Last updated: 2019-12-29

Pi-Plate Python Code To SPI (version 12) discussion Relay Pi-Plate home (Thread)
Pi-Plate Python Code To SPI (version 12) discussion
Last updated: 2019-12-29

Convert to Python to Codesys (version 7) discussion Relay Pi-Plate wiki (Thread)
Convert to Python to Codesys (version 7) discussion
Last updated: 2020-01-02

(no subject) Relay Pi-Plate wiki (Thread)
Last updated: 2019-12-06

Convert to Python to Codesys (version 5) discussion Relay Pi-Plate wiki (Thread)
Convert to Python to Codesys (version 5) discussion
Last updated: 2020-01-03

Pi-Plate Python Code To SPI (version 6) discussion Relay Pi-Plate home (Thread)
Pi-Plate Python Code To SPI (version 6) discussion
Last updated: 2019-12-29

Relay Plate Python Code (version 3) discussion Relay Pi-Plate wiki (Thread)
Relay Plate Python Code (version 3) discussion
Last updated: 2020-01-03

Convert to Python to Codesys (version 2) discussion Relay Pi-Plate wiki (Thread)
Convert to Python to Codesys (version 2) discussion
Last updated: 2020-01-03

Convert to Python to Codesys (version 6) discussion Relay Pi-Plate wiki (Thread)
Convert to Python to Codesys (version 6) discussion
Last updated: 2020-01-03

Pi-Plate Information (version 1) discussion Relay Pi-Plate wiki (Thread)
Pi-Plate Information (version 1) discussion
Last updated: 2020-01-03

<< < 1 .. 58 59 60 61 62 .. 3636 > >> (Page 60 of 3636)

Showing results of 90883

Sort by relevance or date