CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

[SOLVED]Problems with uart+IR transmission
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Huriz



Joined: 31 May 2012
Posts: 13

View user's profile Send private message

PostPosted: Mon Dec 03, 2012 3:41 pm     Reply with quote

Tomorrow I will have the NOR gate in my home, so maybe I can test it. I hope that this is the problem. I will let you know my result.

Ttelmah, I thought that

NAND + PNP == AND + NPN

I'm wrong?

regards
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Mon Dec 03, 2012 6:13 pm     Reply with quote

Using a simple IR receiver:-

Can you detect an output from your IR LED?

As was asked a while ago:-

Does your IR LED still work?

A signal at the drive device collector does not PROVE that you have an IR output.


Mike
asmallri



Joined: 12 Aug 2004
Posts: 1636
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Mon Dec 03, 2012 6:23 pm     Reply with quote

Ttelmah wrote:
asmallri wrote:
Ttelmah wrote:
Seriously, you have probably blown the LED.

IR LED's, typically have a Vf of 1.4v. Now your transistor drops say 0.8v when turned on, so you have:

5-(0.8+1.4)v across the resistor.

This gives a peak current of 2.8/12 = 233mA....



I agree he has probably blown the LED however your maths is wrong because you have confused base-emitter junction voltage (0.7 voltes for a silicon transistor) and the collector-emitter voltage of a saturated transistor which will be of the order of 0.1 volts.

Peak LED current is therefore (5-(0.1 + 1.4) )volts / 12 ohm = 3.5/12 = 291mA

The peak power dissipated in the 12ohm resistor is VI = 3.5 * .291 = 1watt


No, that was why I chose 0.8v, rather than 0.6/0.7v. The figure given is the quoted drop from the data sheet, across the c-e connection when delivering 0.25A, for the BC33740. Smile

Best Wishes


The data sheet I am looking at is from NXP: http://www.nxp.com/documents/data_sheet/BC817_BC817W_BC337.pdf. At 300mA IC it's VCEsat is shown as 0.1V
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Mon Dec 03, 2012 6:48 pm     Reply with quote

Two ways to test your IR LED come to mind - check the voltage across it with a scope - if you see close to the supply voltage across it, it went bye bye. Another way to test, most camcorders (if you have access to one) can see IR. Quick test of the camcorder - point a TV remote at it and see if you see it in the viewfinder. If you can, then you should also be able to see IR from your emitter if it is working. Come to think of it (although I have not tried it) - you may be able to see IR emitters with a smart phone in the video mode looking at the emitter. Seems everybody has those these days. Have to try it when I get home later.

[edit] two different cell phones both "see" the IR led's flashing from my TV remote, so there is another way to "test" your IR emitter :-)

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
asmallri



Joined: 12 Aug 2004
Posts: 1636
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Mon Dec 03, 2012 11:23 pm     Reply with quote

Huriz wrote:
Tomorrow I will have the NOR gate in my home, so maybe I can test it. I hope that this is the problem. I will let you know my result.

Ttelmah, I thought that

NAND + PNP == AND + NPN

I'm wrong?

regards


It is a matter of perspective. If you assume the OUTPUT is the collector voltage of the transistor then:

NAND + PNP = NAND

AND + NPN = NAND

NAND + NPN = AND

However if you assume the OUTPUT is the state of the LED, illuminated or not illuminated then

NAND + PNP = AND

AND + NPN = AND

NAND + NPN = NAND
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Ttelmah



Joined: 11 Mar 2010
Posts: 19589

View user's profile Send private message

PostPosted: Tue Dec 04, 2012 2:17 am     Reply with quote

Huriz wrote:
Tomorrow I will have the NOR gate in my home, so maybe I can test it. I hope that this is the problem. I will let you know my result.

Ttelmah, I thought that

NAND + PNP == AND + NPN

I'm wrong?

regards


Look at the circuit being used, and you will see the problem:
The control here is not standard TTL serial, but on/ -off. TTL serial is -on/ off. Signal the other way up. The NOR circuit is for TTL serial. They are driving the NAND from inverted serial.....

However, forget about looking at what people claim to have done (your diagram could be used like this by someone else later, without knowing it doesn't work.....). Think for yourself.

TTL serial _idles high_. Signal goes _low_ for active states. Your LED needs to come 'on' (generating pulses), when the serial line is low.

So you need:

0 0 led on 1 on base
0 1 led off 0 on base
1 0 led off 0 on base
1 1 led off 0 on base

> NOR

The serial line sits high, when the data is idle (between characters). With the AND, the LED will be generating pulses all this time.....

Best Wishes
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Tue Dec 04, 2012 3:32 am     Reply with quote

Quote:
It is a matter of perspective. If you assume the OUTPUT is the collector voltage of the transistor then:

NAND + PNP = NAND

AND + NPN = NAND

NAND + NPN = AND

However if you assume the OUTPUT is the state of the LED, illuminated or not illuminated then

NAND + PNP = AND

AND + NPN = AND

NAND + NPN = NAND
I don't totally agree with the logic. (Both (NAND+NPN) & (NAND+PNP) are equivalent to AND from logic voltage level perspective)

I've done a truth table
Code:
 ------------------------------------------------------------------------------------------------------------
|                    LOGIC VOLTAGE LEVELS                          |              LED STATE                  |
 ------------------------------------------------------------------------------------------------------------
| In1 | In2 | AND | NAND | AND+NPN | AND+PNP | NAND+NPN | NAND+PNP | AND+NPN | AND+PNP | NAND+NPN | NAND+PNP |
 ------------------------------------------------------------------------------------------------------------
|  0  |  0  |  0  |  1   |    1    |    1    |    0     |     0    |    0    |     1   |    1     |    0     |
|  0  |  1  |  0  |  1   |    1    |    1    |    0     |     0    |    0    |     1   |    1     |    0     |
|  1  |  0  |  0  |  1   |    1    |    1    |    0     |     0    |    0    |     1   |    1     |    0     |
|  1  |  1  |  1  |  0   |    0    |    0    |    1     |     1    |    1    |     0   |    0     |    1     |
 ------------------------------------------------------------------------------------------------------------
Using the following assumptions:-

The transistor logic voltage levels are at the transistor collector.
The effect of either an NPN or a PNP is to invert logic levels.
When NPN logic is 0; LED is ON i.e. 1. When NPN logic is 1; LED is OFF i.e. 0.
When PNP logic is 0; LED is OFF i.e. 0. When PNP logic is 1; LED is ON i.e. 1.

You can do something similar for OR and NOR.


However the point is that you need to do what Ttelmah's keeps telling you.
The required logic is OR or NOR depending on how you drive the LED.
You need the LED to be OFF in the idle state.

Mike
Huriz



Joined: 31 May 2012
Posts: 13

View user's profile Send private message

PostPosted: Tue Dec 04, 2012 1:49 pm     Reply with quote

Hi again.

I have put the NOR with the NPN transistor

this is the result

up = LED signal (i have seen with the phone camera that it works)
middle = 38khz
down = UART signal



the led will be ON when the signal is in UP

I have seen too that the receiver didnt take any data :-S, all the time is a line, maybe i have the receiver bad or something like this, i have bought anotherone, a TSAL2238 to try with another brand receiver.
Huriz



Joined: 31 May 2012
Posts: 13

View user's profile Send private message

PostPosted: Tue Dec 04, 2012 3:45 pm     Reply with quote

Finally I have the solution.

How I have done:

Using a NOR and a NPN transistor like the second picture.

What were my problems?

1- My baud rate 9600, was too big, I have put everything working with 2400 baud rate.
2- How I was sending the data, I mean, I think (I'm not sure that is better with a putc than with a printf).
3- a delay between chars, it wasn't any delay around 50-100 ml between chars, this has been so helpful and it has started working better than without any delay.

Thanks everybody for the help that you have given to me, I'm so grateful to all of you!

NOTE: my led still living :-)

I will change this post to SOLVED

Thanks everybody again!
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Tue Dec 04, 2012 8:53 pm     Reply with quote

Well, it looks like my test for checking the IR signal with a cell phone camera doesn't always work. One person pointed out that it would not see it from a iPhone4 or 5. Checked it with my new iPhone 5 - doesn't see the TV remote even up close, however, my ipod touch, sony camcorder and my son's HTC Incredible do see the IR with no problem. I guess the correct answer is "test your cell phone to see if it can see the tv remote IR and if it can, then you can test the other sources with it".

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
dan king



Joined: 22 Sep 2003
Posts: 119

View user's profile Send private message

PostPosted: Wed Dec 05, 2012 7:02 am     Reply with quote

The latest iPhones have an IR filter so they don't "see" IR data anymore.

As for the IR receiver, many receiver modules will discard continuous data streams as a means of dicriminating noise. More than likely, the data was being ignored by the receiver until it was broken up with delays. Certain modules will receive continous streams of data but they tend to have this clearly marked on the data sheets.
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Wed Dec 05, 2012 9:54 am     Reply with quote

Dan brings up a good point - some years ago I built a quick alarm system that sent an IR beam across the area to watch and discovered that the TV remote control receivers I was using basically ignored a continuous 38khz signal - I had to modulate that signal with a 1khz square wave (gating it) to get an output from the receiver that I could use. I used the same receivers for the finish line in a cub scout derby racer timer - IR led's shining up through holes in the track to the receivers over the track but I did the same thing with transmit 38khz for 1ms then off for 1ms then I looked for 4 "detections" in a row to indicate a car was passing (to eliminate false triggers from nearby flashes etc). That was my first project with PICs and the CCS compiler (let me justify the compiler to my budget director ... I mean my wife)

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group