2

Author Topic: Help for PIC  (Read 3752 times)

0 Members and 1 Guest are viewing this topic.

Offline sambhavTopic starter

  • Jr. Member
  • **
  • Posts: 20
  • Helpful? 0
Help for PIC
« on: January 24, 2007, 11:11:39 AM »
hi..
i am using PIC 16f877 1st time for my project n i need sum help:

1. wat is the i/p voltage range that pic recognizes as logic 0 n logic 1..??

2. i want the pic to drive relays to control switching of ckts... since the max o/p voltage which pic gives is 5v.. i will require relays which switch at less then 5v..
r relays with switching voltage less then 5v readily available..?? if not is der any other option..??

3. is it possible to generate a 40khz continuous square wave of amplitude 5v using a pic ..??if yes... how ?? the pic runs on a 4mhz crystal..

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,659
  • Helpful? 169
    • Society of Robots
Re: Help for PIC
« Reply #1 on: January 28, 2007, 08:06:18 PM »
you can always check the pic16F87X datasheet:
http://ww1.microchip.com/downloads/en/DeviceDoc/30292c.pdf

Quote
wat is the i/p voltage range that pic recognizes as logic 0 n logic 1..??

below 2.5V is logic 0, and above is logic 1. this gets a little fickle as you approach 2.5V, so if thats a problem I recommend testing under the expected conditions.

Quote
i want the pic to drive relays to control switching of ckts

you cannot drive relays directly from a PIC . . . check out this post:
http://www.societyofrobots.com/robotforum/index.php?topic=513.0

Quote
is it possible to generate a 40khz continuous square wave of amplitude 5v using a pic ..??

yeap, its possible. just pulse a digital out line on and off with the proper timing. if you need it to be exact, use an oscope to measure out the frequency.

Offline Hal9000

  • Supreme Robot
  • *****
  • Posts: 338
  • Helpful? 0
Re: Help for PIC
« Reply #2 on: January 30, 2007, 09:13:05 AM »
Just some words I want to throw in:

1. 2.5V would be called the grey area. Try not to fiddle around with stuff in these areas. Go for safe levels (0V or 5V for off or on respectively)

2. I have heard you can drive smaller relays directly from PICs. PICs are very sturdy!

3. You will need to do some calculations to get this frequency spot on. As said, it's all to do with the crystal you use.
"The truth is, you can't hide from the truth, cos the truth is all there is" - Handsome Boy Modeling School

Offline dunk

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
Re: Help for PIC
« Reply #3 on: January 30, 2007, 10:28:47 AM »
Quote
is it possible to generate a 40khz continuous square wave of amplitude 5v using a pic ..??
when i first started playing with PICs i didn't have an oscilloscope for tuning timing routines.
the best way i found of getting accurate timing pulses was to programme in machine code and manually count the number of instructions.
PICs usually process one instruction per 4 clock cycles. (unlike AVRs which process one instruction per cycle. you AVR freaks can get on your soap boxes now...)
some instructions take more than 4 clock cycles (but always a multiple of 4). the data sheets should be able to tell you which ones.

so, simply count how many instructions the program passes through, multiply by 4 and that's how many clock ticks the programme has gone through.
NOP commands can be used to add further delay. (i think it stands for No OPeration or something like that.)

i think the other posts answer your other 2 questions.

dunk.

Offline JesseWelling

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 707
  • Helpful? 0
  • Only You Can Build A Robot!
Re: Help for PIC
« Reply #4 on: January 30, 2007, 11:36:43 AM »
What about the PMW hardware on the 16f877?
I've used 16f877 PWM for motors but you should be able to just set up the 40khrz square wave and let it go if that all you need.

Offline ed1380

  • Supreme Robot
  • *****
  • Posts: 1,478
  • Helpful? 3
Re: Help for PIC
« Reply #5 on: February 01, 2007, 11:13:20 PM »
Just a side question on this topic. Is is better to have the pic do the pwm and hook that up to a mosfet/h-bridge configuration or to a motor control ic. How much diference in code will there be, between the 2 options.
Problems making the $50 robot circuit board?
click here. http://www.societyofrobots.com/robotforum/index.php?topic=3292.msg25198#msg25198

Offline JonHylands

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 562
  • Helpful? 3
  • Robot Builder/ Software Developer
Re: Help for PIC
« Reply #6 on: February 02, 2007, 04:32:09 AM »
Depending on why you want the 40 KHz signal, you might be able to not do it at all on the PIC.

The Sharp IS471F is an IR receiver which generates a 38 KHz square wave on its output pin. I used one for the close-IR sensor on Seeker 2 (http://www.huv.com/miniSumo/seeker2/index.html) and it works really well. You provide it with +5 and ground. It provides you with a digital signal on its output pin to say whether it sees an IR signal, and the other output is the 38 KHz output.

- Jon

 


Get Your Ad Here

data_list