What you want to program is quiet easy, however your brief is not valid, like the arduino the pics outputs can be high or low, they do not tristate.
Not 'strictly' true - simply setting the pin to be an input effectively tri-states it, and is a VERY common technique (particularly used for I2C functions).
Fine ! Can anyone provide me some more information about that program? The programmer and the program refer that chip in their chip selection menus, so I suppose they can program it. Any even simple program as a start will be fine. T least I will have some starting point.Not 'strictly' true - simply setting the pin to be an input effectively tri-states it, and is a VERY common technique (particularly used for I2C functions).
Not 'strictly' true - simply setting the pin to be an input effectively tri-states it, and is a VERY common technique (particularly used for I2C functions).
Tri-state can be override if it is very complicated but will use more parts.
HIGH_SDA: ; high impedance by making SDA an input
bsf STATUS, RP0 ; bank 1
bsf I2C_TRIS, SDA ; make SDA pin an input
bcf STATUS, RP0 ; back to bank 0
return
LOW_SDA:
bcf I2C_PORT, SDA
bsf STATUS, RP0 ; bank 1
bcf I2C_TRIS, SDA ; make SDA pin an output
bcf STATUS, RP0 ; back to bank 0
return
HIGH_SCL:
bsf STATUS, RP0 ; bank 1
bsf I2C_TRIS, SCL ; make SCL pin an input
bcf STATUS, RP0 ; back to bank 0
return
LOW_SCL:
bcf I2C_PORT, SCL
bsf STATUS, RP0 ; bank 1
bcf I2C_TRIS, SCL ; make SCL pin an output
bcf STATUS, RP0 ; back to bank 0
return
Fine ! Can anyone provide me some more information about that program?
include "p12c508.inc"
radix dec
DelayTime equ 15 ; time to hold outputs hig/low (in seconds)
; some variables for the delay
cnt1 equ 7
cnt2 equ 8
cnt3 equ 9
org 0
__CONFIG _MCLRE_ON & _CP_OFF & _WDT_OFF & _IntRC_OSC
START:
MOVLW 0x00
OPTION ; weak pullup on MCLR, wdt prescaler 1:1, wake up on pin change
MOVLW 0xFF ; all inputs
TRIS GPIO
BTFSS STATUS,GPWUF
SLEEP ; wait for pin change / button press
; pin changed, so do the output thin
MOVLW (1<<4) ; GP4 High, GP5 Low
MOVWF GPIO
MOVLW ~((1<<4)|(1<<5)) ; Set GP4/5 as outputs
TRIS GPIO
CALL delay ; delay xx seconds
MOVLW 0xFF ; all inputs
TRIS GPIO
CALL delay ; delay xx seconds
MOVLW (1<<5) ; GP4 High, GP5 Low
MOVWF GPIO
MOVLW ~((1<<4)|(1<<5)) ; Set GP4/5 as outputs
TRIS GPIO
CALL delay ; delay xx seconds
MOVLW 0xFF ; all inputs
TRIS GPIO
MOVFW GPIO
SLEEP ; wait for next button press
delay:
CLRF cnt1
CLRF cnt2
MOVLW (DelayTime * 507 + 50) / 100;
MOVWF cnt3
d1:
DECFSZ cnt1,F
GOTO d1
DECFSZ cnt2,F
GOTO d1
DECFSZ cnt3,F
goto d1
RETLW 0
end
Only 98? While these microcontrollers cannot be erased, you can actually write over the already programmed code (the old program is written over with zeros and the new program can follow - this requires modifications to the HEX), provided there is unwritten space remaining, so you don't have to throw the others out.You just solved 98 12C508A's ...
For my first project I am thinking to use a broken cd player. By pressing the open button the tray motor moves out for 15 seconds provides the logbook and then returns to closed position. When the player has finished the logbook signing, presses the button again to place the log book inside, and the tray closes.I'm assuming you're using a DC motor with a pair of wires coming out of it. You need to reverse the voltage to reverse the direction. A ULN2004 cannot do that. You will want to have a look a an H-bridge driver, or you can use a couple of relays.
As far as keeping idle current low, having pins tri-stated can consume more power (if the voltage floats somewhere between high and low). It's generally better to have them low or high.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?