ssd1306_picaxe40x2 solar heater

andrefcarvalho

New Member
I'm trying to get the code to read the conditions, after adding a maximum setpoint condition the code doesn't work for me as I want, any solution?

Code:
    SYMBOL  tpan = w12'variavel word temperatura de painel
    SYMBOL  tcil = w13'variavel word temperatura de cilindro
    SYMBOL  setpoint = w14'variavel word temperatura de setpoint
    SYMBOL  man = pinC.0 'pin man/aut
    SYMBOL  pump = D.2 'bomba
    SYMBOL  temp1 = D.0 'sensor temp painel
    SYMBOL  temp2 = D.1 'sensor temp cilindro
   
bomba:
    sertxd("painel=",#tpan,"c ","cilindro=",#tcil,"c ","setpoint=",#setpoint,"c ","bomba=",#b32,13,10)
    pause 50
    #rem
        readtemp12 temp1, tpan 'painel
        let tpan = tpan*10/16 'calculo para valores positivos
        readtemp12 temp2, tcil 'cilindro
        let tcil = tcil*10/16 'calculo para valores positivos
    #endrem  
            let tpan=222
            let tcil=223
            let setpoint=300
            if tpan >= tcil and tpan <= setpoint then goto P_on
            if man = 1 and tcil <= setpoint then goto P_on 'def de 1=man./ 0=aut.
            if tpan <= tcil or tpan >= setpoint then goto P_off                  
                       
    P_on:  
        b32=1
        low pump 'bomba ligada
        goto bomba
                       
    P_off:
        b32=0          
        high pump 'bomba desligada

goto bomba
 
Last edited:

Aries

New Member
The obvious thought is "what is the value of man?" In the simulation, it will default to zero. In the real world, it depends on how pinC.0 is connected. If it happens to be at a voltage high enough to appear as logical 1, then your code will always fall through to P_on, which is what you appear to be seeing.
 

andrefcarvalho

New Member
The obvious thought is "what is the value of man?" In the simulation, it will default to zero. In the real world, it depends on how pinC.0 is connected. If it happens to be at a voltage high enough to appear as logical 1, then your code will always fall through to P_on, which is what you appear to be seeing.
value for a toggle in manual, thanks for the help in it, there was no opportunity to come update the topic
Last night I was able to get the code working and I already have the truck to do its function, it seemed to be some problem in the output and I changed the pin

will work like this until i finish the board
23217
23219
23220
 

Attachments

andrefcarvalho

New Member
Good afternoon, after some time using the board, I came across some problems in the truck, after some time littered characters start to appear on the lcd and the truck freezes.
Will I have something wrong with the code or wasn't it meant to work like this for so long?
 

johnlong

Senior Member
Hi and welcome
if I have understood your intentions correctly the following maybe of intrest to you
turn on and off within your values dependent on state of pin C.0
Code:
#picaxe 40x2
 SYMBOL  tpan = w12'variavel word temperatura de painel
    SYMBOL  tcil = w13'variavel word temperatura de cilindro
    SYMBOL  setpoint = w14'variavel word temperatura de setpoint
    SYMBOL  man = pinC.0 'pin man/aut
    SYMBOL  pump = pinD.2 'bomba
    SYMBOL  temp1 = D.0 'sensor temp painel
    SYMBOL  temp2 = D.1 'sensor temp cilindro
       tpan=220
      tcil=223
      setpoint=300
bomba:
    Do
    sertxd("painel=",#tpan,"c ","cilindro=",#tcil,"c ","setpoint=",#setpoint,"c ","bomba=",#pinD.2,13,10)
    pause 50
    #rem
        readtemp12 temp1, tpan 'painel
        let tpan = tpan*10/16 'calculo para valores positivos
        readtemp12 temp2, tcil 'cilindro
        let tcil = tcil*10/16 'calculo para valores positivos
    #endrem  
          if pinC.0=1 then      
                  if tpan>=tcil and tpan<= setpoint then
        
                    high D.2 
            else
                low D.2
            endif 
        else
        low D.2
        endif
    for b0 = 0 to 4 ;0 to 29
        pause 500;pause 2000 for a 1 minute delay
next b0
tpan=tpan+50;for simulation purposes remove
if tpan>370 then
    tpan=200
    endif
    loop
[code]
 

andrefcarvalho

New Member
Hi and welcome
if I have understood your intentions correctly the following maybe of intrest to you
turn on and off within your values dependent on state of pin C.0
Code:
#picaxe 40x2
SYMBOL  tpan = w12'variavel word temperatura de painel
    SYMBOL  tcil = w13'variavel word temperatura de cilindro
    SYMBOL  setpoint = w14'variavel word temperatura de setpoint
    SYMBOL  man = pinC.0 'pin man/aut
    SYMBOL  pump = pinD.2 'bomba
    SYMBOL  temp1 = D.0 'sensor temp painel
    SYMBOL  temp2 = D.1 'sensor temp cilindro
       tpan=220
      tcil=223
      setpoint=300
bomba:
    Do
    sertxd("painel=",#tpan,"c ","cilindro=",#tcil,"c ","setpoint=",#setpoint,"c ","bomba=",#pinD.2,13,10)
    pause 50
    #rem
        readtemp12 temp1, tpan 'painel
        let tpan = tpan*10/16 'calculo para valores positivos
        readtemp12 temp2, tcil 'cilindro
        let tcil = tcil*10/16 'calculo para valores positivos
    #endrem 
          if pinC.0=1 then     
                  if tpan>=tcil and tpan<= setpoint then
       
                    high D.2
            else
                low D.2
            endif
        else
        low D.2
        endif
    for b0 = 0 to 4 ;0 to 29
        pause 500;pause 2000 for a 1 minute delay
next b0
tpan=tpan+50;for simulation purposes remove
if tpan>370 then
    tpan=200
    endif
    loop
[code]
I have the slightly different code, yesterday I could not get from him, the question I have now is the truck send strange characters to the truck and then block, not doing its function, is normal?
 

andrefcarvalho

New Member
Code:
'***********************************************************************
'                   zona de controlo para painel
'***********************************************************************
'let setpoint = 360'usar em caso do valor na eeprom for absurdo, mais tarde tentar usar comandos serial
read 254, word setpoint ' define valor guardado na eeprom
pause 10

sensor_read:

        readtemp12 temp1, tpan 'painel
                'let w12 = w12+offset 'offset de leitura
            let tpan = tpan*10/16 'calculo para valores positivos
        
        readtemp12 temp2, tcil 'cilindro
                'let w13 = w13+offset 'offset de leitura
            let tcil = tcil*10/16 'calculo para valores positivos   

    val_setpoint:
    
            if setm = 1 then
                sertxd("Setpoint=",#setpoint,"C ",13,10)
                goto val_menu
            else
                goto val_write
            end if   
        
            val_menu:
                    if up = 1 and dw=0 then setpoint_inc
                    if dw = 0 and dw=1 then setpoint_dec
                    if setm = 1 then val_menu
            goto val_write
            
            setpoint_inc:'incremento de setpoint
                if up = 1 then setpoint_inc
                setpoint=setpoint+var_inc
                goto val_write
                
            setpoint_dec:' decremento de setpoint
                if dw = 1 then setpoint_dec
                setpoint=setpoint-var_inc
                        
        val_write:
                
                row = 6
                col = 7
                
            gosub setposition
                
                if setpoint >= 10 then
                aByte = setpoint / 100  // 10 + "0" : Gosub DisplayChar
            else
                aByte = " "             : Gosub DisplayChar
            endif
                aByte = setpoint / 10  // 10 + "0" : Gosub DisplayChar
                aByte = " "             : Gosub DisplayChar
                aByte = "C"
                
                if setm = 1 then val_setpoint
                
                write 254, word setpoint' grava valor na epprom entrada 255
                pause 10
            
            
                
            

        bomba:' label  para defeni??o de estado consuante os sensores
        
                    if man = 1 then P_on 'vai ignorar o valor de temperatura dos paineis
                    if tpan <= setpoint then P_off'valor de setpoint para defenir que os paineis n?o trabalham antes do valor
                    if tpan <= tcil then P_off'valor de setpoint para defenir que os paineis n?o trabalham antes do valor
                    if tpan >= setpoint then P_on'valor de setpoint define a que temp os paineis come?am a circular a agua
                                
            P_on:   
                if tcil <= tempmaxcil then
                    
                        b32=1
                        low pump 'bomba ligada
                
                    else
                        goto P_off
                endif
                                
                    row = 5
                    col = 7
                        gosub setposition
                        
                    for index = 67 TO 69
                        read index,aByte
                        gosub displayChar;
                    next index   
                goto temp_1'para n?o passar o estado da bomba a desligado
                                
            P_off:
                b32=0           
                high pump 'bomba desligada
                
                    row = 5
                    col = 7
                        gosub setposition
                                        
                    for index = 70 TO 72
                        read index,aByte
                        gosub displayChar;
                    next index   
            
    temp_1:'display value painel

            row = 3
            col = 8
        gosub setposition
                
            if tpan>=10 then
            aByte = tpan / 100  // 10 + "0" : Gosub DisplayChar
        else
            aByte = " "             : Gosub DisplayChar
            endif
            aByte = tpan / 10  // 10 + "0" : Gosub DisplayChar
            aByte = "."                   : Gosub DisplayChar
            aByte = tpan       // 10 + "0" : Gosub DisplayChar
            aByte = " "             : Gosub DisplayChar
            aByte = "C"             : Gosub DisplayChar
            
    temp_2:'display value cilindro

    
            row = 4
            col = 10
            
        gosub setposition
            
            if tcil>=10 then
            aByte = tcil / 100  // 10 + "0" : Gosub DisplayChar
        else
            aByte = " "             : Gosub DisplayChar
            endif
            aByte = tcil / 10  // 10 + "0" : Gosub DisplayChar
            aByte = "."                   : Gosub DisplayChar
            aByte = tcil       // 10 + "0" : Gosub DisplayChar
            aByte = " "             : Gosub DisplayChar
            aByte = "C"             : Gosub DisplayChar
            
            
    sertxd("Painel=",#tpan,"C ","Cilindro=",#tcil,"C ","Setpoint=",#setpoint,"C ","Bomba=",#b32," ON=1 0FF=0",13,10)
    
    #rem
    if reload_inc < 65535 then ' limpeza de lcd
        inc reload_inc
    else
        goto main
    endif
    #endrem
goto sensor_read
 

lbenson

Senior Member
It's not normal. Can you post a good photo of the "strange characters"? What has the truck been doing when it gets the strange characters and freezes?
 

Hemi345

Senior Member
Since you're sertxd'ing some values, have you tried connecting your project to your computer when you see the OLED corrupted to see if the program is still functioning correctly? That would help determine that it is just your OLED code that is misbehaving.

Sorry but your code is very hard to follow/interpret with all the goto's mixed with gosubs. Another reason the program may go haywire is an overflow or variable you're reusing for the display. Try rewriting your program without using any goto statements.
 

hippy

Technical Support
Staff member
the question I have now is the truck send strange characters to the truck and then block, not doing its function, is normal?
It's not entirely normal but can happen. External events can cause hiccups in operation, lighting strikes nearby, ESD, power brownouts, induced electrical noise when something like a relay switches or a motor starts up, and so on. The longer a program operates for the greater the likelihood of such an event happening is.

If the controller on the display board has been thrown out of kilter it may not display what has been sent to it correctly even if the PICAXE is operating correctly. PICAXE operation may also be affected.

That this starts to happen after some time suggest the PICAXE program may have executed some part of its program which isn't doing as expected rather than some external event.
 

andrefcarvalho

New Member
I apologize for the time without answering, but due to the situation I could not come here, yes may be what the hippy is referring to, now I have had the device turned off, however maybe a way around the problem would be the truck doing a reset After a while, is it a good option?
 
Top