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.
suggestions for the IDC plug cable

what suggestions for plugging into the ICD socket on the Junebug to program in circuit.
purchasing a plug and a ZIF socket
be nice if the plug had cable attached already(I hate attaching cable to plugs)
am assuming I need an IDC 10 pin female plug??(I realize I only need 5 pins but the 5 pin plugs won't lock into place.
 
going to use a 40 pin hard drive cable

epoxied the cable to connector then going to cut out 10 pins
should work. Need to test if the new code (change the Rb0 to sense a high signal thus eliminating the extra transistor Q2 in schematic.The PIR outputs a 3v signal
bought a perfboard and LM386 from rat shack as well
going to try out after epoxy cures.
going to order a zif socket and ICD cable from Mouser
 

Attachments

  • Capture4-15-2009-8.51.59 PM.jpg
    Capture4-15-2009-8.51.59 PM.jpg
    133.7 KB · Views: 251
added an LM386

took 2n2222 out, added an LM386 to con5(RB3)
changed pieces of the code and POW!!
them deer are gona run for the hills (hopefully)
hav'nt figured out how to leave the formatting in when copying n pasting
do I nessarly need to erase the chip when changing the code. sometimes I have to hit F10 twice??
{
*****************************************************************************
* Name : UNTITLED.BAS *
* Author : Doug Bezaire *
* Notice : Copyright (c) 2009 [select VIEW...EDITOR OPTIONS] *
* : All Rights Reserved *
* Date : 4/16/2009 *
* Version : 1.0 *
* Notes : *
* : *
*****************************************************************************
}
{
************************************************** ***************************
* Name : sound freq gen.BAS *
* Author : *
* Notice : Copyright (c) 2009 [select VIEW...EDITOR OPTIONS] *
* : All Rights Reserved *
* Date : 4/15/2009 *
* Version : 1.0 *
* Notes : *
* : *
************************************************** ***************************
}
Device = 18F1320
Clock = 8 // 8MHz clock
Config OSC = INTIO2, WDT = OFF, LVP = OFF

Dim NOT_RBPU As INTCON2.7
Dim TMR1IE As PIE1.0
Dim TMR1IF As PIR1.0
Dim TMR1 As TMR1L.AsWord
Dim Speaker As PORTB.3
Dim SpeakerTris As TRISB.3

//global variables
Dim Seed As LongWord, Tone As Byte
Dim i As Byte

//half period delays = clock speed divided by 2*frequency
Const Tones(18) As Word = (2000000/12000,2000000/10000,2000000/8000,2000000/6000,2000000/4000,1000,
2000000/12000,2000000/10000,2000000/8000,2000000/6000,2000000/4000,1000,2000000/12000,2000000/10000,2000000/8000,2000000/6000,2000000/4000,1000)

//interrupt routine
Interrupt MyInt()
T1CON.0=0 //stop timer
TMR1=-Tones(Tone) //reset period
T1CON.0=1 //restart timer
If Tone=5 Then //if silence
Speaker=0 //speaker off
Else //otherwise
Toggle(Speaker) //make sound
EndIf
TMR1IF=0 //clear interrupt flag
End Interrupt

Function Rand(Range As Byte) As Byte
Dim i As Byte, feed As Bit, temp As Word
For i = 0 To 7 //generate 8 bits
Feed = Seed.30 Xor Seed.27 //make new bit
Seed=Seed*2+Feed //shift seed left and add new bit
Next
Temp=(Seed And 255) * Range //change Rand from 0 to 255
Rand = Temp/256 //to 0 to (Range-1)
End Function

//main code starts here

OSCCON = $72 //select 8MHz internal clock
NOT_RBPU=0 //WPUs on port B
ADCON1=$70 //all digital
T1CON = %10000001 //pre=1
Tone=5 //no sound please
TMR1IE=1 //enable timer 1 interrupt
Enable(MyInt) //set interrupt going
SpeakerTris=0 //Setup Port
Seed=$12345678 //seed random number
While(TRUE) //repeat forever
If PORTB.0=0 Then //if button 1 pressed add PIR here
For i = 1 To 200 //play 20 tones
Tone=Rand(5) //each tone is random frequency
DelayMS(25) //and for 1.00 seconds
Next //end for loop
Else //otherwise
Tone=5 //silence
i=Rand(255) //make rand more random
EndIf //end if condition
Wend //end of while loop
 
Well aside from code tags I'd say you're starting to get the hang of things. The PIC is erased automatically when programmed, sometimes the programmer can't stop the PIC to get into program mode so it may take an extra try.
 
adding an LM386 to the mix

connected an LM386 for a 20 db gain
changed the code as posted (sounds like a telegraph after 20 cups of coffee or 4 RED BULLS)
took out the input PIR transistor
have to change PORTB.0=1
hope the pic can decipher the 3v input trigger?
the LM386's are pretty much obsolete
any other suggestions
I hope the LM386 will run ok as shown in my schematic. It works but that don't make it right
 

Attachments

  • Capture4-16-2009-10.24.21 PM.jpg
    Capture4-16-2009-10.24.21 PM.jpg
    115.6 KB · Views: 259
little help on plugs n sockets

looking to add the header as suggested by ne80be to program PIC in circuit.
can't decide what to buy??
looking at XG4M-1030-T over at Mouser but not sure if this mates w/ the IDC plug on the junebug
then can I connect a 5 cond cable(or go w/ the 10 cond cable) from the Junebug to the female plug that plugs in on the circuit board being programed?
 
Add a user programable 4POS DIP input??

had a light bulb go on in my head this morning= a programmable dip switch connected to several inputs on the 18F1320 (other than PORTRB.0 which is the PIR input)
these dip switches (4) would input maybe a BCD input thus changing the different variables in the code.
For i = 1 To 200 //play 20 tones
Tone=Rand(5) //each tone is random frequency
DelayMS(25) //and for 1.00 seconds
Next //end for loop

like if RB2 is low then change the variable i
If PORTB.5=1 then I=Ix10
If PORTB.5 =1 then DelayMs=(250)
am sure there is a way to do this using BCD input
this way the owner of the unit can change the sound output at will(if the deer get used to the sound then change the sound)
another reason I want to add a header so I can reprogram the PIC if needed.
any suggestions
 
Locking IDC connectors will work but you really don't need the locking part. I'll look for the part today and supply a digikey #

Any 0.1" 2x5 header will likely work. You can even get just pin headers like 1x40 strips and break em off as 1x5. You only need the connection for as long as it takes to program the target PIC.
 
add dip switch and header

The 4 pos dip switch is so the user can change the delay and how many tones.
Not sure what else I could change to make the unit sound different.
need to play with code.
perhaps several different speeds or maybe change the speed in middle of run cycle??
 

Attachments

  • Capture4-17-2009-12.07.36 PM.jpg
    Capture4-17-2009-12.07.36 PM.jpg
    139.4 KB · Views: 250
I was following Junebug

connections on RB0, RB2, Rb5 (the 3 switches.
I was contemplating adding resistors as the battery won't last as long without
4 seperat resistors feeding the dip switch?
about 1 meg to really limit current??
Not to change subject I was looking for an enclosure and found a PVC weatherhead with removable cap.
the PIR can sit under the little roof
may have to post pic but first need to locate a picture.
it looks like 6 AAA batteries, pc board, and speaker will fit??
need to double check.
thanks for the tip on adding a programing header
hopfully will have a unit up and running by Monday.
Will order my BMW next Friday ---LOL
 
The DIP switch doesn't need pullups. The 18F1320 has built in pullups you can enable on PORTB.
Look in the data sheet for RBPU

Remember sleepy PICs draw very little power, run it as slow as you can. Also sleep will halt the PIC till something wakes it up.

Move the DIP switch to RB0,1,2 & 4
A little bit of programming can move bit 4 to 3...
 
Last edited:
why are RB better than RA?

I really only need 2 dip switches
one to change delayvariable
and one to change # of tone variable
I need to breadboard at this point so I can get a feel of whats going on.
the dip switch is just some added fluff. An added selling point The customer can change as wanted. KEEP THEM deer guessing or perhaps find a better setting as well as program updates via the ICD header.
IF I add (probally will if it dosn't shorten battery life too much the dip switches)how or what to change on the code?
If RA0 = 0 then Delay = Delay + 100
 
PORTB has a built in pullup resistor network that can be enabled. You can also disable it to reduce power consumption. The LM386 is going to chew through the batteries more.

I do have an untried idea. A TC4424 could probably drive a small speaker in a push pull fashion much louder than the LM386.

You wouldn't need the diodes and the speaker would go where the motor is.
**broken link removed**
 
I said gnd I figured he use the
built in pullups you can enable on PORTB.
so he can sleepy by the pic.
I didn't want to see him short the pins to gnd and hit them with 5 volts. I all ways use a 10k to gnd
on the switch the internal pullups are about 40k. The 10k is only a 500 Microamps
 
Last edited:
Status
Not open for further replies.

Latest threads

Back
Top