Adding A/Ds to 12F683 in Oshonsoft

Status
Not open for further replies.
hi,
It works for me in simulation,
You have this remmed out Define SIMULATION_WAITMS_VALUE = 1 'SIMULATION ONLY

So the sim will take ages to run.
E
It works for me also in simulation (with Define SIMULATION_WAITMS_VALUE = 1 'SIMULATION ONLY remmed in) I rem it in and out as needed. It doesn't work properly in the circuit though, only GP2 flashes but not GP4 and GP5.

Camerart.
 
hi.
OK, I will relook at your program, get back to you.
E

EDIT:

I cannot see a problem in the program for those two LED's
Check that you have the LED's the correct way around and that they are connected to those pins.
E
 
Last edited:
hi.
OK, I will relook at your program, get back to you.
E
EDIT:
I cannot see a problem in the program for those two LED's
Check that you have the LED's the correct way around and that they are connected to those pins.
E
Eric,
I have a test panel for electronics, so the LEDs are fine.

I did some tests, where I simplified the code, and changed whether a LED was on or off. I have attached the simple code.

If the LEDs are set to go on, then they stay on, so on the code I sent, only one LED comes on and stays on. If they are set not to come on then they don't light at all. No flashing.

UPDATE: I found that the voltage from the LED pin was 2.5V Which implies that it is flashing far too fast. I did a test where the LED was only set to turn on, and the voltage is now 5V.

This appears to be something to do with the internal clock. I'm not using XTALs, but if I can't find an answer will reluctantly add them.


Camerart.
 

Attachments

  • 12F683 c test.bas
    695 bytes · Views: 363
Last edited:
I've been trying as many combinations as possible, and the attached code is the best I can get.
With T1CON commented out AN0 and AN1 turn GP2 and GP5 on ok, but the start up LEDs flash momentarily, so the clock is too fast.
With T1CON not commented out GP5 never turns on.

Any ideas?

Cheers, Camerart.
 

Attachments

  • TIMER INTERRUPT and AD Modified header TEST-AN0- AN1-GP2-GP5 S.bas
    2 KB · Views: 364
hi,
Downloaded your code, will look.
I dont have a 12F683 on the bench so I cannot check with hardware.
E

EDIT:
Remove the 1000 Waitms in the Toggle loop, let me know how that effects it.
You have a 0.5sec ISR running and a 1 Second wait.
 
Last edited:
hi,
I have simplified your code in order to check out the LED's
Try this in your PIC
E.
 

Attachments

  • ledtestV1.bas
    1.2 KB · Views: 392
Remove the 1000 Waitms in the Toggle loop, let me know how that effects it.
You have a 0.5sec ISR running and a 1 Second wait.[/quote]

There is no Toggle LOOP (I hope I'm correct) but if you mean my test start up LEDs, if the 'WAITMS 1000' is removed from this, then there are no perceivable flashes.

The 0.5 second and 1 second wait is something that was set up for interrupts. I'll explain in the next reply.
 
hi camerart,
Why is the TMR1 interrupt enabled if its not being used.?

I am slowly building up a TIMER program with A/D inputs for future use, I have to build up these modules, so I can call on them for useful programs I have planned.

Once I have the LEDs turning on ok, and the A/Ds working too, I'll then add the proper timer back in.
 
hi,
I have simplified your code in order to check out the LED's
Try this in your PIC
E.
Only GP2 flashes.

I have tried lots of different combinations of inputs and outputs, to get 2x leds to flash, while also having 2x A/D inputs and 1x digital input. I have only achieved 1 or 2 results, like the one I posted in #24, which is almost there apart from when WAITMS is used.
I wonder if perhaps WAITMS should not be used while the INTERRUPT routine is working???
 
hi,
I have run the program in 'real' time, look at these three images, they show an interval of 0.5sec LED ON/OFF as you would expect.

Is it possible you have a damaged PIC on these two pins.??
E
 

Attachments

  • AAesp01.gif
    20.7 KB · Views: 350
  • AAesp02.gif
    24 KB · Views: 356
  • AAesp03.gif
    15.9 KB · Views: 351
Last edited:
hi,
I have run the program in 'real' time, look at these three images, they show an interval of 0.5sec LED ON/OFF as you would expect.

Is it possible you have a damaged PIC on these two pins.??
E

I now use a proper lab test bed, because of odd results on the circuit board, I've tried 3xPICs including a new one, and I have moved the lead going to the LED, around the chip and still only GP2 flashes.

Is it possible that PICKIT2 is not properly programming? Or, as this is taking both of us a lot of effort, should I use a different chip?
 
16F648A and 16F819, I was kind of hoping to stick with 8 PIN, but it's not that important.

hi,
If you wish you could mail me a couple of your 12F683 PIC's and I will program and test them.?

I have some 16F819 on the shelf, so we could compare in hardware.
E
 
hi,
If you wish you could mail me a couple of your 12F683 PIC's and I will program and test them.?

I have some 16F819 on the shelf, so we could compare in hardware.
E

I'm happy to post them to you, I'll pop them in the post tomorrow.

I've already made a remote heater from anywhere to my vehicle. This project is a spot welder for cells for an electric bike, and in the future I want to make a GPS follower, perhaps that will need a larger chip?

I'll wait for you to play with them before changing Chip.

Camerart. That's it for tonight, thanks.
 
Last edited:
I now use a proper lab test bed, because of odd results on the circuit board, I've tried 3xPICs including a new one, and I have moved the lead going to the LED, around the chip and still only GP2 flashes.

Have you checked the LED on GP5, its transistor and connections? Can you write a simple program to turn GP5 On and run the program to see if it is ever capable of turning on?
 
Have you checked the LED on GP5, its transistor and connections? Can you write a simple program to turn GP5 On and run the program to see if it is ever capable of turning on?

I presume you mean 'resistors' not 'transistors' In the circuit there is an ok resistor. On the test bed the resistors are built in.

If you check #24 you will see that everything is working, but the timing is wrong, as it's so fast that the start up flashes are milliseconds, not 1 second, and WAITMS commands don't work properly. I can get all 3x LEDs to flash 1 second, but with no A/D in, and I've moved inputs and outputs to many different patterns with no good result. The code I posted on #24 is the best.

On the PINS that I am having trouble with, there is a PIN selection for a clock-in and I think this is being interfered with.

Cheers, Camerart.
 
hi,
I have tried the assembled program that Oshonsoft creates in MPLAB, it works fine.

Just in case the TMR0 IE flag is not reset to 0 on power up, add this INTCON

Code:
OPTION_REG.T0CS = 0
OPTION_REG = %10000000

INTCON = 0

'TRISIO = %00000100  'GPIO,0-1-2-4-=LED,  GPIO,3 =IN  GPIO,5 unused
 
I notice that there are no A/D inputs and GP5 is unused, this all makes a difference to the outcome. Best wait till you have the chips, to see if the same thing happens once the simulator show success and once in the circuit no success. Using the code I posted on #24. Perhaps you might find out where I'm going wrong.

Cheers, Camerart.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…