Adding A/Ds to 12F683 in Oshonsoft

Status
Not open for further replies.
With all this to-ing and fro-ing I lost the plot!!! camerart Have you the latest full code..
I lost it a couple of days ago, so I know what you mean

The code posted in #24 will work if the T1CON is commented out, so if you turn up a voltage to '>100' in either A/D one or the other LEDs will go on till it is lowered again, but it is running far too fast for you to see the 'Start up LED' flashing. Once T1CON is un-commented, then GP5 will not light, perhaps no LEDs will light. It all looks ok, in the simulator, but not real life (for me)

Camerart
 
At the moment..

AN0 increased to 100... Red LED comes on..
AN1 increased to 100 Green LED comes on..
Red LED flashes according to value of AN0 ( On time )
Red LED flashes according to value of AN1 ( Off time )​
Or....
AN1 increased to 100... Green LED comes on..
AN0 increased to 100 Red LED comes on.. Red LED flashes according to value of AN0
Red LED flashes according to value of AN0 ( On time )
Red LED flashes according to value of AN1 ( Off time )​

If both AN0/1 are lower than 100 then both LED's are off..

This makes no difference if T1CON is on or off...
 
Are you doing this with an actual 12F683 or on the simulator? It works for me also in the simulator, but not in circuit. I've sent Eric some chips to try.
 
hi,
Even the IF tests are remmed out the problem shows in simulation.
Camerart, try this.
Rem out as the following lines...
Use the Program Tracking Option.
When it executes the Break , single step thru the code.
rled will become set when the rled=1 statement is executed.
But will reset when you execute the gled=1 statement! this should not happen

Do you follow that OK.?

Code:
loop:
'Adcin 0, an0  'Sets first pulse
'Adcin 1, an1  'Sets second pulse

Break
'If an0 >= 100 Then
rled = 1  'ON IN SIMULATOR = OFF
'firstpulse = an0
'WaitMs an0
'firstpulse = 0
'Else
'rled = 0  'OFF IN SIMULATOR = ON
'Endif

'If an1 >= 100 Then
gled = 1  'ON IN SIMULATOR = OFF
'secondpulse = an1
'WaitMs an1
'secondpulse = 0
'Else
'gled = 0  'OFF IN SIMULATOR = ON
'Endif


Goto loop
 
hi camerart,
Using MPLAB, the problem is with your ANSEL
you have ANSEL=47; which makes GP2 analog!

make it ANSEL=43 and retry
ANSEL = %01000011
E
 
Stepping through the code from the BREAK command. At 'rled = 1' then RLED turns on, at 'gled' = 1 then GLED turns on and RLED stays on.

If I run the simulator at 'NORMAL' speed from the beginning, then the simulator stops at 'rled = 1' and sets the speed rate to STEP BY STEP.

I'm not sure if I did what you were asking?
 
camerart !! I simulate in ISIS at full speed.... The code from post #24 doesn't have any "t" variable in the loop so timer 1 isn't doing anything??

What Eric said is correct... ANSEL should be 0x43... or 0x53 ( to increase the aqu time a little...)
 
hi camerart,
Using MPLAB, the problem is with your ANSEL
you have ANSEL=47; which makes GP2 analog!

make it ANSEL=43 and retry
ANSEL = %01000011
E

camerart !! I simulate in ISIS at full speed.... The code from post #24 doesn't have any "t" variable in the loop so timer 1 isn't doing anything??

What Eric said is correct... ANSEL should be 0x43... or 0x53 ( to increase the aqu time a little...)
I tried 0x43 and 0x53. Same symptoms on the circuit.

Eric will receive the Chips in a day or two, best wait till he's had a go with them.
 
Eric will receive the Chips in a day or two, best wait till he's had a go with them.

OK, will wait for the PIC's, but that ANSEL was incorrect at 47.

When that circuit is operating correctly, what are you expecting to see on the LED's etc.?? just summarise.

E
 
OK, will wait for the PIC's, but that ANSEL was incorrect at 47.

When that circuit is operating correctly, what are you expecting to see on the LED's etc.?? just summarise.

E
I've changed the ANSEL.

The start-up flashes should turn on/off about a second. When the A/D 'voltages' go up and down, then the corresponding LED will turn on and off. First try commenting out T1CON.
 
hi camerart,
The 12F683 package you posted has not arrived as at 11:00 Today.
I have built the project board ready for your PIC
E
 
Hi E,

I posted it a couple of days ago, 1st class, so it should be there by now. I put the PICs in a letter, and I'm wondering now if it haven't pass the post office slot test. If that's the case you might be charged parcel post or something. If so let me know and I'll send the extra postage. Perhaps I should have flattened the legs

C.
 
R Eric said:
OK, will wait for the PIC's, but that ANSEL was incorrect at 47.
??? ANSEL 0x43 there are only two adc inputs....

camerart So nothing happens on a real chip.... Usually this is down to osc settings.. The reason I say this is because this is the only thing ISIS doesn't simulate!!
 
hi C,
If they dont turn up I will buy 6 pieces.
Dont worry about the postage.
E

E,
I asked today at the post office, and they said true it wouldn't go through the small letter slot (I haven't kept up with today's postal system!) and you will most probably get a £1;50 + postage bill. Sorry about that, and that you aren't well. Hope you get better soon.

I'm happy to send some more, properly this time

Camerart.
 
Last edited:
??? ANSEL 0x43 there are only two adc inputs....

camerart So nothing happens on a real chip.... Usually this is down to osc settings.. The reason I say this is because this is the only thing ISIS doesn't simulate!!

I,
Correct, nothing happens on the real chip, but looks ok in the simulator. Earlier in the thread I said it might be the clock, so what you say sounds correct. It appears that either if something is connected to the 'clock' pins, or perhaps the inputs are set to IN, then it stops the clock regulator, which seems to change the WAITMS. Anyway, one way or another Eric will have some to test. Unless of course it's ME!

UPDATE: I just tried a test with the initial 'start up flashes' with 100X WAITMS 1000. This did slow it down a bit, and I estimate that it would need 250X WAITMS 1000s to equal 1 second.

Camerart.
 
Last edited:
You haven't got the frequency set wrong? I mean in the IDE..... The chip has a really accurate internal crystal... Also make sure the INTOSC is set to IO function not clockout...
 
You haven't got the frequency set wrong? I mean in the IDE..... The chip has a really accurate internal crystal... Also make sure the INTOSC is set to IO function not clockout...
The frequency set to 4Mhz. the INTOCS is INTOSCIO. I chose the chip because of its timing accuracy.

Let's see what Eric comes up with, I've been known to make mistakes!

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…