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.
Have you seen this you have it on your computer it swordfish help
 

Attachments

  • help.PNG
    help.PNG
    80.9 KB · Views: 279
The 20ma RB3 can source is not enough to drive a speaker, you need to add the simple resistor and transistor driver as shown by be80be.

What you're going to find out is with programming there are almost unlimited ways of doing something. It's confusing at first but stick with it and you'll get the hang of it.
And perhaps MrDEB may add a diode or RC across the speaker coil to protect the transistor.
 
He don't need one. It's a speaker not a motor. Use a diode on a motor or relay not a speaker.
 
I guess mvs sarma dosn't know about deer

Deer and other critters are attracted to diodes and RC circuits!!
you will have deer from miles around comming to munch on your garden w/ diodes and RC circuits --LOL
oh I come up with a new name for this device = CRITTER RIDDER
 
He don't need one. It's a speaker not a motor. Use a diode on a motor or relay not a speaker.
You may be correct if the driving transistor is working in linear mode and handling a sine wave. but an unbiased transistor driving a square wave into a speaker at its collector, I feel, definitely produces back emf and should be protected. I saw many such schematics where such protection is provided. Shortly, i shall be able to provide links to confirm my thought.
 
You can if you want to mvs sarma people have argued this for years but a speaker use the
back-emf to make sound
The subject of "back-EMF" from speaker drivers is one that has surfaced from time to time across many decades of audio engineering, and it always seems to get much discussion, much disagreement, and not a lot of conclusions reached. Atmasphere brought this up in the related thread of "why amps sound different", and it inspired me to do a couple of experiments.
its not going to hurt his little npn because it never going to send back more then his little npn can handle.Now if it was a 12volt motor then for sure put a diode on it.
and it inspired me to do a couple of experiments
1.It lowered the output of the speaker with it and the sound wasn't right. Diode in there
2.With out the sound was good it never hurt the npn. No diode on it.
 
Last edited:
looking at using the pwm code

you posted be80be.
but using something less elaborate than a RNG.
going to connect the 10k/npn to breadboard etc then run your code
have to come up with a way to change the DUTY variable you put in.
any suggestions??
only need to go from 2khz to 6khz randomally so a RNG prg that uses 5 numbers or maybe a few more.
THEN I need to trigger the pic with a PIR sensor.
 
What PIR are you using. I been playing with it but I can make better sound not using the PWM and using this
Code:
Device = 18F1320
Clock = 8 // tells the compiler the FOSC speed
Config OSC = INTIO2, WDT = OFF, LVP = OFF
Include "Utils.bas"
Dim out As PORTB.3
OSCCON = %01111111
SetAllDigital

 Low (PORTB.3)
 While true
 
    High (out)
    DelayUS (1400)   // justs change this to change sound
    Low (out)
    DelayUS (700)  // and this to
   
   
 Wend
then set a timer and run the code with more delay
works better then the PWM
 
PIR sensors etc.

found on Ebay but SURE Electronics sells same.
Why cheaper on Ebay??
They have a spec sheet on their website on controlling w/ PIC
what frequency does this code produce?? remember 2-6 khz back n forth--want to drive them critters away.Be nice to have it sound different each time it runs.
Will have to look and see how to set up a timer.



**broken link removed**
 
You can change it how ever you want that just shows you how easy it is to get sound. thats about 11khz if my math is right. There are PIR that work like a switch easy to use with a pic almost a no brainer. That pir is easy to use. Not very good but easy to set up the range is to short.
 
Last edited:
they were cheap

I purchased 5 units to test out the CRITTER RIDDER
just need the PIC set up as I started designing a PC board
 
have to ask=

caculated for 11khz?
what caculations are these based on.
I looked at the utilis.bas file ????
what caculs are needed??
 
I divided the clock by the delayUs which is about 11khz tone
The Utils.bas gives you command to use so you don't have to code it your self.


Subroutines and Functions

function Reverse (pValue as TType, pAmount as byte) as TType

function Digit (pValue as TType, pIndex as byte) as byte

function Min (pValueA, pValueB as TType) as TType

function Max (pValueA, pValueB as TType) as TType

sub Swap (byref pValueA, pValueB as TType)

function HighNibble (pValue as byte) as byte

function LowNibble (pValue as byte) as byte

sub SetAllDigital ()
 
delay is 1400

1400 divided by 8000 = .175
are you sure its not multiply??
1400x8000 = 112000
700 x 8000 = 5600
am I missing something??
 
TimeMe in swordfish

is this several different timers or all as one.
not sure of what I need
1 = when PIR detects motion it sets the sound prg to run
2 = sound program to change frequencies from 2000 - 6000 hz back and forth
3 = after say 5 - 10 seconds the pic shuts off waiting for another occurrence.
be80be has posted several sound codes=THANKS
now I need to figure out how to increment and decrement the sound code value
I was thinking just a loop that adds say 100 to one variable then substracts 100 from second variable

TimerA()=0

A=700, B=1400 //A and B determine sound frequency see be80be post above
A + 100, B - 100
until A >= 1400
A= 700, B= 1400
if TimerA()=100 then wend

I have a hunch this is close (I remember programming the VIC 20, C64 and the C128)
yes I is an old fart
 
VIC 20, C64 and the C128
I had all three and a lot more What's hard is swordfish is not the same as the basic you used then so I have to do a lot of reading
and I just started back coding haven't done any in over 25 years till about year and a half ago i used a stamp it's easy to code but cost to much. been picking about 8 months still learning lol
 
reading your posts you appear

to be an expert programmer?
I myself am just starting out with this PIC stuff.
 
I didn't say I can't The point was It's been a long time and just started back. Got to do a
lot of reading to get up to speed. Swordfish has a module for the timer. You can set like
3 events 1 if pir gos off then do low sound then high sound it's here. Swordfish Wiki | SwordfishUser / Timer0 browse
 
I browsed that module

looks like greek but will try and understand it.
found a website that describes how to creat a sine wave using a PIC
My PIC Projects
almost at the bottom
?????????
 
Try pressing the PICs on the Junebug hard. LEDs were not blinking sometimes in my case. It sure was a problem of loose PICs.

Ow my bad. just disregard the post :)
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top