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.

Components for use with a PIC

Status
Not open for further replies.

Alan_Bates

New Member
Hello, first let me say I'm a Software Developer and in way over my head with electronics. I looked at the 'New to Electronics' post and at the companies supplying components but it has left me even more confused. I'm working with a PIC system using **broken link removed** schematic. I've managed to get the features on the board working, such as the LED and Ethernet stack but not knowing anything about electronics I'm not sure how to go about adding additional components. I want to add some kind of components to the free PIC pins to measure temperature, humidity, soil moisture, Co2 and light level.

Could a kind soul recommend components a village idiot could order in the UK?

Thankyou very much for your time and I apologise if this is in the wrong forum.
 
Hi Alan,

I am fairly new to electronics and also own a PIC development board - they are really so versatile - thinking about getting an olimex PIC webserver my self...

Anyway - you will need to interface external circuits to the GPIO (General Purpose Input/Output) pins. As you have a nice prototyping board, these should be routed out to the prototyping area. By the look of your board (from the website), the GPIOs (the ones left after the ethernet and other interfaces) are connected to the pin header on the side. You will need to connect your sensing circuits to these (unless they are also connected to the first hole next to them (it is hard to see)). The circuits have to be designed so their output matches the GPIO pin requirements. this will either be a digital TTL level logic signal (on or off) (and usually about 3.3v - i think the top rail (line of holes) is a 3v3 supply (but check your manual - if not, I spy a 3v3 pin by the pushbutton). This allows you to, say, link a switch between the 3v3 supply and a gpio pin, set it to an input (in code), and read it. This is probably where someone else will bite my head off and tell you that you need to limit currents (which you can just do with a resistor I'm sure - the max current that your PIC can sink or source is 25mA from the datasheet) - and probably chuck some capacitors in for good measure - this is where my knowledge ends - there always seem to be a lot of capacitors in analog circuits... :D

However if you are using something like a temperature sensor then it will usually give you a varying voltage as an output. Therefore you cannot use a digital input. You could use an analog to digital converter and feed the binary into digital inputs - but that would be a waste. Instead the PIC does that for you and provides some analog 'A/D' pins. These can be found in your datasheet or manual) . However you will need to make sure the voltage output is the right range for your PIC pin and also again that currents are limited. This will require an 'analog' circuit, whic I am not comfortable designing. As for sensors you can use any semiconductor really - even a simple diode - but i suggest a proper tenp sensor like an LM35 - and acording to most schematics you can just connect Vcc to +5v, gnd to ground and Vout to an A/D pin. BTW you will need to configure the pin for analog to digital conversion (ADC) - but you're a software guy and you've implemented the stack already so that should be easy - if in doubt, datasheet!

Basically, you should be able to hunt around online for simple PIC interface circuits - ideally there will be one output wire going off to the right with a pin name on it for the PIC - nice and easy!

eg
12F675 tutorial 4: Making an LM35 temperature recorder. - but just the LM35 bit!

That's as far as I can go - good luck!

Laurence
 
Hi Alan,

I am fairly new to electronics and also own a PIC development board - they are really so versatile - thinking about getting an olimex PIC webserver my self...

Anyway - you will need to interface external circuits to the GPIO (General Purpose Input/Output) pins. As you have a nice prototyping board, these should be routed out to the prototyping area. By the look of your board (from the website), the GPIOs (the ones left after the ethernet and other interfaces) are connected to the pin header on the side. You will need to connect your sensing circuits to these (unless they are also connected to the first hole next to them (it is hard to see)). The circuits have to be designed so their output matches the GPIO pin requirements. this will either be a digital TTL level logic signal (on or off) (and usually about 3.3v - i think the top rail (line of holes) is a 3v3 supply (but check your manual - if not, I spy a 3v3 pin by the pushbutton). This allows you to, say, link a switch between the 3v3 supply and a gpio pin, set it to an input (in code), and read it. This is probably where someone else will bite my head off and tell you that you need to limit currents (which you can just do with a resistor I'm sure - the max current that your PIC can sink or source is 25mA from the datasheet) - and probably chuck some capacitors in for good measure - this is where my knowledge ends - there always seem to be a lot of capacitors in analog circuits... :D

However if you are using something like a temperature sensor then it will usually give you a varying voltage as an output. Therefore you cannot use a digital input. You could use an analog to digital converter and feed the binary into digital inputs - but that would be a waste. Instead the PIC does that for you and provides some analog 'A/D' pins. These can be found in your datasheet or manual) . However you will need to make sure the voltage output is the right range for your PIC pin and also again that currents are limited. This will require an 'analog' circuit, whic I am not comfortable designing. As for sensors you can use any semiconductor really - even a simple diode - but i suggest a proper tenp sensor like an LM35 - and acording to most schematics you can just connect Vcc to +5v, gnd to ground and Vout to an A/D pin. BTW you will need to configure the pin for analog to digital conversion (ADC) - but you're a software guy and you've implemented the stack already so that should be easy - if in doubt, datasheet!

Basically, you should be able to hunt around online for simple PIC interface circuits - ideally there will be one output wire going off to the right with a pin name on it for the PIC - nice and easy!

eg
12F675 tutorial 4: Making an LM35 temperature recorder. - but just the LM35 bit!

That's as far as I can go - good luck!

Laurence

Thanks very much for your reply! Sorry I have taken so long to reply back but I've been busy, as usual. I managed to get a temp sensor I found working and get a value out of the ADC. It does seem to work(I get a higher value the hotter it is) but I do not have any information about the temp sensor and it's not linear. So I've ordered a couple tmp36's. Apparently I can attach them directly to the PIC. Temperature sensor tutorial - Using the TMP36 / LM35

I'm also looking for a linear humidity sensor if you know of any I can attach directly as well. Do you know if I can attach a small DC motor directly to a PIC? I'm too scared to try as I understand the PIC can only supply 25mA, so I need a mosfet to interface between the two.
 
Please don't connect motor directly to PIC! :eek: The motor will try to pull way too much current, and possibly fry it. Also, the back-emf will kill it if the current draw doesn't!

Don't want to let out the magic smoke!!! :)

If your motor draws less than 1A, you could use just a NPN transistor, like a 2N2222. If you need to drive it in both directions, look for H-Bridge circuits. Here's the one I'm using to automatically open/close my blinds :D

The diodes are there so the back-emf from the motor can flow happily to 5V, instead of killing my AVR. The are called 'fly-back diodes'. :D

**broken link removed**

I only had NPN around, so its a lil different from standard h-bridges...

Oh, and Sparkfun sells a breakout board with a combination humidity & temp sensor.

https://www.sparkfun.com/commerce/product_info.php?products_id=8257

They also sell a popular H-Bridge chip:

https://www.sparkfun.com/commerce/product_info.php?products_id=315

If you don't know Sparkfun, you should!
They have all kinds of products for the electronics tinkerer / developer, plus lots of tutorials.
 
Last edited:
Hi Alan,

here is a combined temperature/RH sensor, the Sensirion SHT11.

It has 14bit resolution for both, temperature and humidity, is calibrated during manufacturing and requires serial interfacing with the MCU you want to use.

Regards

Boncuk
 

Attachments

  • SHT11..pdf
    331.4 KB · Views: 168
Last edited:
Hi Alan,

I would definitely disagree on the motor to PIC idea!! Except for maybe a small pager motor - but anything larger would burn it out fairly quick - as Birdman Alan said, the back EMF would fry it if the forward current draw didn't (that's to do with inductance - see this wikipedia article for more detail.

So yes you would need either a transistor, MOSFET or H-Bridge controller to give it enough headroom.

Shame about the temperature sensor - it's always nicer to scrounge a part than have to buy one! The TP36 looks great from what I saw on Ladyada's site, and should be easy to interface straight to the ADC.

For motor control I would go for a H-Bridge (depending on size really - but as you're asking about temperature and humidity sensors, I imagine it'll be quite a bit bigger than a pager motor!), as they do offer much versatility and are quite rugged - they can take a lot of crap from the motor end!

For the humidity sensor - here's a link to another thread. Google searches are your friend. Once you have found a likely candidate then pull up the datasheet (google part no. [and get ready to sift through some spammy searches if it's a rare one]).

Hope that helps,

Laurence
 
That you very much everyone, I ordered a HIH-5030-001 humidity sensor, it looks like it will do the trick. One last problem I'm having is how to drive the motor. It accepts 1.5V or 3V, I just want it to turn On or OFF and the speed is not important. All the H-Bridges I've looked at can't handle voltages so low. Any recommendations on how to attach this motor to my PIC board?

Thanks once again!
 
Well I've ran my h-bridge circuit off of 5 volts. There just common 2n2222 transistors. Since the electricity has to go through two transistors, the voltage is dropped to the motor by about 1.4 volts. (Each diode drops about 0.7 volts). What that means is when powered with 5 volts, my circuit will give the motor ~3.6 volts.

Honestly, that should be fine for your motor. If you wanted exactly 3 volts, just add an extra diode to drop it another 0.7 volts...
 

Attachments

  • H-Bridge 2-Direct&#.jpg
    H-Bridge 2-Direct&#.jpg
    12.7 KB · Views: 167
Hello Birdman Adam. Thanks for the post. That circuit looks a little complicated for me. Surely, since I just want to turn the circuit on or off I can use a single transistor? If I powered the motor by a single AA battery could I have a transistor single receive an ON signal (5V) and enable the fan?

I found the full details of the fan while trying to work this out.

Operating voltage: 1.5 to 3V
No load speed: 9,100 rpm
No load current: 200mA
Speed at max efficiency: 6,990 rpm
Current at max efficiency: 660mA
 
O yes! A single transistor will work just fine for turning the motor on and off in one direction. Since your current is 660mA, you have lots of options for transistors... I would just use a common 2N2222.

Here's a schematic that should work. The chip is just an example of a micro-controller input. Any MCU could be used to turn on the transistor. I have calculated the base resistor to be around 200Ω. The diode is there to allow the back-emf from the motor to flow happily back to 5V, instead of killing your transistor or MCU. :)
 

Attachments

  • motorandtransist&#.png
    motorandtransist&#.png
    5.3 KB · Views: 158
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top