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.

Junebug help??

Status
Not open for further replies.
I looked at the schematic

so thats what they call charlieplexing. heard of the term but never knew what it really ment.
what is JPUG#1 a member or a web site or ??
hopefully can get this timer loop worked out. Then I can advance with project.
 
Mrdeb there no book for swordfish but if you read the help with you'll learn alot look at
this code it's smaller and shows you how timers work.
Code:
// 18F1320@ 8MHz - they are just used here for clarity...
device = 18F1320
clock = 8

include "ISRTimer.bas"          

// constant ID to 4 * 16 bit timers...
const
   Timer1 = 0,
   Timer2 = 1,
   Timer3 = 2,
   Timer4 = 3
      
// OnTimer1 event...
event OnTimer1()
   toggle(PORTB.0)
end event

// OnTimer2 event...
event OnTimer2()
   toggle(PORTB.1)
end event

// OnTimer3 event...
event OnTimer3()
   toggle(PORTB.2)
end event

// activate the timer module...
Timer.Initialize

// initialise the timers - refresh every 1000Hz (1ms)...
Timer.Items(Timer1).Interval = 50        // 50ms
Timer.Items(Timer1).OnTimer = OnTimer1   // timer event handler
Timer.Items(Timer2).Interval = 250       // 250ms
Timer.Items(Timer2).OnTimer = OnTimer2   // timer event handler
Timer.Items(Timer3).Interval = 500       // 500ms
Timer.Items(Timer3).OnTimer = OnTimer3   // timer event handler
Timer.Items(Timer4).Interval = 2000      // 2000ms, no event handler

// enable the timers...
Timer.Items(Timer1).Enabled = true
Timer.Items(Timer2).Enabled = true
Timer.Items(Timer3).Enabled = true
Timer.Items(Timer4).Enabled = true

// start processing all timers...
Timer.Start

// main program loop...
while true
   // this is a polled timer, not event driven - check to see
   // if it has timeout...
   if not Timer.Items(Timer4).Enabled then
      toggle(PORTB.3)
      Timer.Items(Timer4).Enabled = true
   endif
      
   // background flash LED...
   high(PORTB.7)
   delayms(500)
   low(PORTB.7)
   delayms(500)
wend
All need to do is set timer for 1 sec have it inc counter every sec till 60
then just let it count the minutes till it hits 20 at 20 turn on your sound and use the sec counter to count for that say it counts to the first minute then turns sound back off and starts counting for 20 minute
 
Last edited:
maybe I is blind but where is ISR timer bas.

I looked in the swordfish library and under samples.
will look deeper at swordfish site??
 
It appears to be working??

I changed the ms times (just took off some zeros
then changed all the ports to A.0 and A7
I get the first 2 LEDs on Junebug to alternate back and forth.
now I need to figure out the timing.
QUESTION = the code has 4 timers. Do I need all four or can I delete 2 as I only need to change the state of one pin from HIGH to LOW??
will fiddle with it later. I have a date with some trout and cub scouts
 
You can do it with One
set it to count for 1 sec then it writes and 1 to say sec when sec get to 60 it writes
and 1 to min. When min get's 20 it runs your code If it run 60 sec go back and do it agin
 
Last edited:
Mr Deb you missed the whole point of the sample I showed you It' shows you how the timer works if you learn that You can write your own code. If you just slap bit's of code
together your never going to have a good program. I no I did it I wanted it all at first but. It works for simple things but not what you want.
 
Im mad at myself today!!!

lets see I connected my battery to a breadboard not realizing it had a possibility of 9v POOF goes a PIC
I proceeded to break off a pin on that PIC anyway(inserted and bent when inserting into my socket for programming
I then proceeded to insert the next chip in backwards - not sure if its blowen as I tried programming a 3rd chip and nothing happens??
have resistors and LEDs connected on breadboard to ports B0, B1, B6, B7
no LEDs lighting up??
maybe I have the dip switches wrong on the Junebug??
I looked back at the beginning of this post and I am pretty sure all dips are off.
tried with 1-3 on still no go
yes I changed the code to B ports
got to be something stupid I am doing???
 
Egads June Bug problems = ME

trying to program an in circuit PIC using junebug
I have the dip switch w/1-3 all off and the rest on.
programed the PIC and it works
go to reprogram with different code and the previous code stays in but no new code??
Im sure I am doing something wrong??
 
You could be loading your old hex I've done that a time or two here you something to look at.
[embed]http://www.youtube.com/v/WTlV2xHH5yE&hl=en&fs=1&[/embed]
 
3rd chip and nothing happens??
have resistors and LEDs connected on breadboard to ports B0, B1, B6, B7
no LEDs lighting up??

Aren't B6 and B7 the incircuit serial programming connections?

Mike.
 
B6 & b7

looking at the pinout , yes but I assume it is also RB6 & RB7
pin 12 = RB6/PGC
pin 13 = RB7/PGD
 
Give this a try.

Unhook the resistor and LED from RB7 just to remove a possible problem.

Using the PICkit2 tool (not MPLAB)

Use the troubleshooting wizard under Tools to see if you can id and connect to the chip. (I expect you can) What is the VPP voltage ?

If VPP is much less then 11V you have problems.

If VPP is close to 12V you should be able to erase the chip. Leave the troubleshooter and give it a try (still in PICkit2 software). If it does not work the first time try a 2nd and a 3rd.

If you can erase the chip try programming it with a hex file and erasing it again.

If this all works try putting you resistor and LED back on RB7 and see if it stops working.
 
If you use the pickit2 as a debugger then you can't use B6 & B7 in your circuit. As a programmer you can use them but with some restrictions. As you have lots of other port pins to play with just leave B6 & B7 as the ICSP pins. You're describing programming problems and so I thought this may be the cause.

Mike.
 
RB6 and Rb7 they sure can keep you from programming the pic if you have them loaded
I had that happen was using the debug mode and leds on portb
 
I found the problem!!

I ran pickit2 troubleshooter and I get a voltage erron = short!!
afet looking at the board ( a perf board w/ 18pin socket and cable soldered to it I looked and tested with DVM etc.
I find the Vdd and Vcc shorted!
I looked w/ mag glasses etc??
I decided to rewire the board etc.
upon unsoldering I find a single strand of wire shorting out(stranded wire about 16-18 gagg stranded wire so strands are really small)
Well I have been using this same board numerous times with no problems.
I guess it just needed to be bent in the right direction)
I rewired board and all looks good!!
reprogramed one of the chips I inserted in backwards and it looks good!
I went throught the trouble shooter etc and it passes!!
need to insert PIC into breadboard and tryout the timer code be80be posted.
then cut it down to one timer and figure out how to get 20 minutes from it.
then going to order some more chips but see it I can get something cheaper for 18 F series??
 
IT'S alive!!

thanks to be80be my life just got more confusing--lol
I got the ICD board straighten out and inserted the PIC in breadboard w/ 4 LEDs.
now to figure out what the timers are doing , then use only one timer for a 20 minute delay.
Just need to decipher whats going on in the code as to whats going on with the LEDs.
going to change the ms values to maybe help??
then insert an increment counter to loop every 20 minutes.
QUESTION this code uses timeron instead of delay. I assume this is better??
 
trying to dechipher this code to one timer for 20 minutes.
changing the timer value dosn't seem to affect timer 4.
timer 1 seems to react to change in value.
and what is the background flash leds? they just stay on
I am guessing that when timer 4 times out the LED port B.0 pin 8 comes on for a set time (presently about 5 seconds).
am sure I am missing something real simple. the while true and if not statements are kinda throwing me off I think.


Code:
// 18F1320@ 8MHz - they are just used here for clarity...
Device = 18F1320
Clock = 8

Include "ISRTimer.bas"          

// constant ID to 4 * 16 bit timers...
Const
   Timer1 = 0,
   Timer2 = 1,
   Timer3 = 2,
   Timer4 = 3
      
// OnTimer1 event...
Event OnTimer1()
   Toggle(PORTB.0)//pin 8
End Event



// activate the timer module...
Timer.Initialize

// initialise the timers - refresh every 1000Hz (1ms)...
Timer.Items(Timer1).Interval = 20        // [COLOR="Red"]led lights for 5 seconds[/COLOR]
Timer.Items(Timer1).OnTimer = OnTimer1   // timer event handler
  // timer event handler
Timer.Items(Timer4).Interval = 2000      // 2000ms, no event handler

// enable the timers...
Timer.Items(Timer1).Enabled = true

Timer.Items(Timer4).Enabled = true

// start processing all timers...
Timer.Start

// main program loop...
While true
   // this is a polled timer, not event driven - check to see
   // if it has timeout...
   If Not Timer.Items(Timer4).Enabled Then
      Toggle(PORTB.0)//pin 8
      Timer.Items(Timer4).Enabled = true
   EndIf
      
   // background flash LED...
   High(PORTB.7)//pin 13// [COLOR="Red"]why does the LED on pins 12 & 13 stay on all the time?[/COLOR]
   DelayMS(50)
   Low(PORTB.6)// pin 12
   DelayMS(50)
Wend
 
MrDeb you no I tried the delayMS(20000) it doesn't work
why does the LED on pins 12 & 13 stay on all the time
set your ports
Code:
[COLOR="Red"]trisb =$0  //sets all pins to output on PORTB [/COLOR]
[COLOR="Red"]PORTB =$0  //sets all pin low on PORTB[/COLOR]
// main program loop...
While true
   // this is a polled timer, not event driven - check to see
   // if it has timeout...
   If Not Timer.Items(Timer4).Enabled Then
      Toggle(PORTB.0)//pin 8
      Timer.Items(Timer4).Enabled = true
   EndIf
      
   // background flash LED...
   High(PORTB.7)//pin 13// why does the LED on pins 12 & 13 stay on all the time?
   DelayMS(50)
   Low(PORTB.6)// pin 12
   DelayMS(50)
Wend
 
Last edited:
delayMS(20000)???

im a C18 guy but isnt 20000 to much for that function to handle?

How about delay like:
Loop this 20 times:

delayMS(200)
delayMS(200)
delayMS(200)
delayMS(200)
delayMS(200)
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top