American Dryer OPL

Thread Starter

R!f@@

Joined Apr 2, 2009
9,918
I'll corel draw something on how the program should work. Gimme some time.I just sent the quotation to them. I will get an answer on sunday I think
 

Markd77

Joined Sep 7, 2009
2,806
BCD to 7 seg chips would be good, but then the LEDs could only display numbers, and not the messages like "E1".
The easiest way (I think) to get the exact timing is by having a regular interrupt on Timer 0 which can also do the multiplexing. There's a little bit of code needed because 1MHz divided by 256 isn't a whole number, but I've done it before and it's pretty easy.
It's slightly easier with a 4.096MHz crystal because that divides nicely, but it's not much harder with a 4MHz one.
I've made a little start on the interrupt section, but it's not worth posting yet, and I don't know if you want it public.
I think the recommended capacitors for 4MHz are 15pF, best double check.
Another option would be to have a second PIC connected to the first by the serial pin. The second PIC could then do the display and free up a lot of pins on the main PIC.
 

nerdegutta

Joined Dec 15, 2009
2,684
Ok..
here is the first flow chart I came up with...
man this is tougher than I thought..

Is this the correct way?

need some sleep. :(
It's a start, and we get the general idea. The sensor is on the door, right?

Another option would be to have a second PIC connected to the first by the serial pin. The second PIC could then do the display and free up a lot of pins on the main PIC.
Interesting...
 

Markd77

Joined Sep 7, 2009
2,806
Another option would be to use a couple of 74LS164 8 bit serial in parallel out shift registers for the displays. They would have to be common anode because the registers are rubbish at sourcing current, but can sink 8mA.
That would just use 2 pins for the displays, I'm not sure how many pins you need.
If using an extra PIC for the displays it could be pretty much anything with enough pins, I've got code to do serial input without a serial module.
 

Markd77

Joined Sep 7, 2009
2,806
Here's some basic code to get you started, there may be a few things I've forgotten like disabling analog features and comparators.
Also the pins I've used are probably wrong.

All it does is multiplexing and timekeeping, and they simulate OK.

Rich (BB code):
    list      p=16f876            ; list directive to define processor
    #include <p16f876.inc>        ; processor specific variable definitions
    __CONFIG _CP_OFF & _WDT_OFF & _BODEN_ON & _PWRTE_ON & _XT_OSC & _WRT_ENABLE_ON & _LVP_OFF & _DEBUG_OFF & _CPD_OFF
w_temp        EQU     0x7E        ; variable used for context saving
status_temp   EQU     0x7F        ; variable used for context saving
    cblock 0x20
    PORTAtemp
    PORTBtemp
    digit1pins
    digit0pins            ;right digit
    LOOPCOUNT
    multiplexcount
    microsecondsH
    microsecondsM
    microsecondsL
    second_flag
    seconds
    minute_tens
    minute_units
    endc


    ORG     0x000             ; processor reset vector
    clrf PCLATH
      goto    init              ; go to beginning of program


    ORG     0x004             ; interrupt vector location
    movwf   w_temp            ; save off current W register contents
    movf    STATUS,w          ; move status register into W register
    movwf    status_temp       ; save off contents of STATUS register
    bcf STATUS, RP0            ;bank 0

    movf multiplexcount, W
    addwf PCL, F
    goto digit1
    goto digit0
digit1
    bcf PORTAtemp, 7            ;toggle transistor pins
    bsf PORTAtemp, 6
    movf digit1pins, W            ;display digit
    movwf PORTB
    incf multiplexcount, F
    goto digitdone
digit0
    bcf PORTAtemp, 6            ;toggle transistor pins
    bsf PORTAtemp, 7
    movf digit0pins, W            ;display digit
    movwf PORTB
    clrf multiplexcount
digitdone
    movf PORTAtemp, W
    movwf PORTA
    bcf INTCON, TMR0IF


;Interrupt gets here every 1024 cycles, so subtract 1024 from a
;counter that was preset to 1000000.
;When the counter overflows add 1000000 so there are no cumulative
;errors
    movlw 4
    subwf microsecondsM, F        ;microseconds - 1024
    btfsc STATUS, C
    goto ISR_end
    movf microsecondsH, W    ;check if zero
    btfsc STATUS, Z
    goto reset_timer            ;1 second is up
    decf microsecondsH, F
    goto ISR_end
reset_timer        ;just add 1000000 (0x0F4240) to microseconds
    movlw 0x0F  
    addwf microsecondsH            ;no need to check for overflow
    movlw 0x42
    addwf microsecondsM            ;no need to check for overflow
    movlw 0x40
    addwf microsecondsL, F
    btfsc STATUS, C
    incf microsecondsM, F
    bsf second_flag, 0


ISR_end
    movf    status_temp,w     ; retrieve copy of STATUS register
    movwf    STATUS            ; restore pre-isr STATUS register contents
    swapf   w_temp,f
    swapf   w_temp,w          ; restore pre-isr W register contents
    retfie                    ; return from interrupt

;table is at start to avoid page crossing 
bcdto7seg            ;bit 2 not used here (decimal point)
    addwf    PCL, F    ; Jump into the lookup table
    retlw    B'11101011'    ; Return segment code for 0
    retlw    B'00100001'    ; Return segment code for 1
    retlw    B'10111010'    ; Return segment code for 2
    retlw    B'10110011'    ; Return segment code for 3
    retlw    B'01110001'    ; Return segment code for 4
    retlw    B'11010011'    ; Return segment code for 5
    retlw    B'11011011'    ; Return segment code for 6
    retlw    B'10100001'    ; Return segment code for 7
    retlw    B'11111011'    ; Return segment code for 8
    retlw    B'11110011'    ; Return segment code for 9
    return

init


    MOVLW 0x20                    ;clear files
    MOVWF FSR
NEXT
    CLRF INDF
    INCF FSR, F
    BTFSS FSR, 7
    GOTO NEXT

    clrwdt
    banksel OPTION_REG
    movlw b'11000001'
    movwf OPTION_REG
    banksel INTCON
    movlw b'10100000'        ;timer0 on interrupts on
    movwf INTCON            ;prescaler 4 so interrupt every 1024 cycles

    banksel TRISA

    movlw b'00010001'
    movwf TRISA
    clrf TRISB

    movlw b'10001110'
    movwf ADCON1
    bcf STATUS,RP0                    ;bank0
    movlw 0x0F
    movwf microsecondsH
    movlw 0x42
    movwf microsecondsM
    movlw 0x40
    movwf microsecondsL


main
    btfss second_flag, 0
    goto normal
    bcf second_flag, 0
    incf seconds, F            ;just increment seconds and digits to display
    movlw d'60'
    subwf seconds, W
    btfss STATUS, Z
    goto update_display
    clrf seconds
    incf minute_units, F        ;easier to store digits separately
    movlw d'10'
    subwf minute_units, W
    btfss STATUS, Z
    goto update_display
    clrf minute_units
    incf minute_tens, F

;do some more checks to see if total time elapsed



update_display
;calculate digit0pins and digit1pins
    movf minute_units, W
    call bcdto7seg
    movwf digit0pins
    movf minute_tens, W
    call bcdto7seg
    movwf digit1pins

normal
; remaining code goes here (needs to take less than 1 second)
    goto main 


        END                       ; directive 'end of program'
 

Markd77

Joined Sep 7, 2009
2,806
Oops, I thought that was the one you were using (from the recent schematic), I guess I should have asked.
Shouldn't take you too long to alter it.
 

nerdegutta

Joined Dec 15, 2009
2,684
Nice...

Is the door mechanically locked? If not, then perhaps you should include a "Check door" sensor during the cycles.

What I mean is: What if someone opens the door in the middle of a cycle?
 

nerdegutta

Joined Dec 15, 2009
2,684
Maybe it is easier to have a switch on the door, that cuts power when the door is open. I'll bet there was someone thinking of safety when constructing the dryer.

I had a dryer once. When it was running, you couldn't open the door, and when a program was finished, it took about 30-60 seconds before you heard a "click" and you could open the door.

I think you need to think about safety, and don't underestimate human stupidity....
 

Markd77

Joined Sep 7, 2009
2,806
This is probably how you are going to do it anyway, but probably reflects better how the actual program will work.
My picture isn't as good looking as yours and it's not the full cycle.
 

Attachments

Top