Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC12C508

Status
Not open for further replies.

DimitriM

New Member
I know it is old, programmed only once and such. BUT a friend who used to chip some game console has given me 100 pieces. Unused/Unprogrammed and in their package. So I thought they can be useful in some way. Like simple timers ( NE555 is a good example). But learning how to program them in my age is a bit of pain in the ... ! I already found that Arduino's are much easier for me, and I have even made some projects & programming them. I got a K150 USB programmer and downloaded microbrn.exe program.
And now the question: Can anyone help me with a program that can be used as a basis to use those chips as timers? I only need a starting push button as input and two outputs that will be one HI and one LOW for some time ( let's say for 15 seconds). After the 15 seconds the two outputs should be reversed for another 15 seconds and then become open circuits.
It will be very helpful if changing some values in the program could alter the timing period. Can you help me on that ? it is a pity to throw away 100 pieces, but learning a new language - programmer - program and such, is to much for my capabilities.
Any volunteers ? Thank you !
 
Hi,

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.
You could use switches on the other 3 gpio which would allow the 15 seconds to multiplied or divided by up to x 8

The trouble with programming for someone else is the customer always changes their mind and you end up having to write things over and over again.

Not familiar with that programmer / software, can it actually program the 12C508 ?

Also be careful if you do play around with them on the programmer, each one has a unique oscillator calibration value written into the last memory address and it should not be overwritten /erased, or at least recorded first .
 
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).
 
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.
I liked the idea of switching for the time. Tri-state can be override if it is very complicated but will use more parts. Can you propose some easy program to use, so I will not need to learn a new programming technique for just one project? Please !
 
Tri-state can be override if it is very complicated but will use more parts.

It doesn't use any parts, and only a few of lines of code - here are some examples from my I2C tutorial.

Basically one line for the tri-stating, and two lines to select the correct bank and restore it.

Code:
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
 
Hi,

Yes, thanks for the examples, must confess, though obvious, the TRIS never occurred to me , never too old to learn, :happy:
 
Fine ! Can anyone provide me some more information about that program?

Just looking at that programmer and software it does state it can program the 12C508 chip, so I would first suggest you connect it all up and see if you can just Read out its memory and get its Osccal value from the last location, something like 34nn as shown in the pic
 

Attachments

  • 000105.jpg
    000105.jpg
    71.8 KB · Views: 528
Hi,

The Zip contain the .hex program code for the 12C508 chip, as shown in the screenshot .

You just need to add VDD and VSS.

I have tested it on my 12C675 chip ok ,but the code for the 508 is slightly different and I can only simulate it as shown.

At power up the two output ports will give you one high and one low output for 15 seconds, then they go high impedance inputs , as Nigel showed, for another 15 seconds before they loop around again.

That should allow you to test a chip out.

Will be able to add input switches if the above works.
 

Attachments

  • 15sec.zip
    18.4 KB · Views: 294
News from my progress: The program works but only for the led on out/pin 3. It starts glowing for 15 seconds, goes off for 15 second and keep cycling that indefinitely. But pin 2 does not do anything.
So here are the questions/ needs :
1) I need the two outputs as 1-Hi / 2-Low for 15 seconds just one time.
2) After those 15 seconds the two pins stay in tristate for 15 seconds.
3) On the completion of this 30 seconds the two outputs go 1-Low / 2-Hi for 15 seconds.
4) After 15 seconds go to tristate for ever. They must remain at that state.
5) If it is easy to do, all that sequence may start from a simple push button. That will make the circuit more flexible but is not mandatory. I can, if needed shorten this input pin and use the battery insertion as the starting event.
6) Any info on how to extend or shorten the time will be useful, since not all of my projects will need the same time window.
To be more specific, I will use that circuits to start - wait - reverse small motors. My hobby (besides electronics!) is Geocaching. That gives me the possibility to exercise physically my body and the opportunity to create some electromechanical y emerging boxes that will be very unusual in the game.
If it is not too much trouble, your knowledge and my fantasy will (maybe !) make the game more interesting !
 
You can try the attached HEX file. The source code and MPLAB project files are there too if you want to change the time delay (change the 'DelayTime' value in main.asm - the maximum value is 50 seconds). GP4/5 are the outputs, GP0 or GP1 can be the inputs (connect a button from GP0 to ground), GP3 is reset.

Code:
    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
 

Attachments

  • SimpleTimer.zip
    11 KB · Views: 244
Thank you-thank you-thank you! You just solved 98 12C508A's and made a geocacher ( and maybe/I hope ) many more happy! :D
 
Sure, you're welcome.
You just solved 98 12C508A's ...
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.
 
If I start building my projects and be in need of new chips I probably will be buying some compatible models but still is a very clever and imaginative solution.:happy:
What you will use if you have to draw more current ( a bigger motor ) ? I think of the ULN2004 . Do you propose something different? Keeping idle current low, is essential, because projects will stay long at standby mode.
 
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.
 
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.
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.
This scenario can be repeated for various movement with motors , like: box that comes down from a tree trunk or cave, or sings that appear for short period to show the final coordinates using a tiny motor like the ones in mobile phone vibrator.
Just to describe my thoughts about the use of μc in geocaching.
About ULN2004: If I drive the inputs from my μc outputs I can't understand why it is not good for the job.
Maybe the tristate as selection is wrong in my case but if we follow the simple Hi/Low configuration, then the motor will get the positive to one of his poles for 15" and move forward and the next 15" to the other one and move in reverse.
The other pole will change to the opposite for the same time and then both will stay Hi or Low so the motor stays idle.
I am wrong?
 
You need an h-bridge (or something else) in order to drive the motor either way - there's no need for tri-stating anything in such a scenario.

You also don't use timed delays to set the open/closed position (it would be rubbish) - use the limit switches already in place on the mech, it's what they are there for, and how the CD player itself works.
 
I will use the same chip for various projects. The CD tray was just one paradigm. The up down motorized -string movement has no position switches. Or the case of two led's that show for 15'' the North and East coordinates of the box.
If tristate is power consuming then it will of course be ripped off.
Maybe in some of my projects the player have to brink his own 3 AA batteries - they are very common to our GPS units- and have to place them in a battery holder to energize the circuit. A kind of bronze pipe, hidden somewhere and not easily spotted from non players.
This eliminates the power consuming problem but complicates the installation. Maybe some sun powered cells can be used in few places with low consumption led. So many uses and many openings to my thoughts You have given me, with your help! Really I feel very blessed for this!
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top