How is this achieved?

obroni

Member
Hi,

I was wondering if anybody could shed some light on how a guy has managed to achieve 3 things in this circuit and if they are possible to do on a picaxe:-

http://www.lasertagparts.com/images/MT CORE RevH 01.gif

1. Basically on the PIC in the diagram, pin 11 and 13 turn on two FETs which modulate serial data over a 38khz pwm carrier wave. Somehow the guy is also able to detect if current is flowing through the pwm FET to know if the IR led is functioning/connected. Anybody know how this is done.

2. Using either pin 27, 21 he is also able to detect if the IR receiver is connected. I am guessing that he might be relying on the fact that IR recievers output 5v when they are not receiving, but if it was not connected, would you not need a pulldown resistor to stop the pin floating?

3. He uses pin2 to control a LCD display but can also measure the voltage between the two 1k65 resistors. How is this possible??? Surely the voltage would upset the data going to the LCD, or because it will only be 3.6v (1/2 of 7.2v), it neither registers as on or off? Even further still how can he be using a pin as both an input and output at the same time???

Sorry for a load of questions in one go, but its really been bugging me how it works. I'm afraid he doesn't give out the source code, which makes this hard to guess how it works.
 

hippy

Ex-Staff (retired)
No idea how he's checking if the IR LED's or FET are present but could be pulling up an output, switching low and seeing what capacitance ( created by having a FET ) is on the line or not. Or something similar.

Using pin 2 for LCD control and for voltage reading is easier. When the pins is an output high or low it over-rides the voltage divider and sends 0V / 5V to the LCD line so that operates as expected. When the pin is made input, the LCD floats the line so the voltage divider over-rides the LCD line, then that's read using an ADC read.
 

Dippy

Moderator
All these claims: are they in some documentation somewhere?
Or are they your interpretation of an article you have read.

1. There is a trickle of PWM all the time the code requests it and PortC.0 high gives it a strong ground to modulate it.
I can't see any detection capability unless there are some component characteristics used.
Personally, for greater confidence, I would include a photo-tr or photo-d acting as a feedback like many Laser LEds.

2. Pin 27 PortB.6 simply triggers an FET switch - probably to switch on the IR sense module.
Pin 21 PortB.0 senses IR sensor output I assume?
Yes, it will (with most IR modules) show high when connected and powered.
But, in theory, floating when disconnected.
I haven't got all the details so guessing here, but the only way I could imagine detecting whether connected is to see if the pin can be forced high AND low and then read the Port input - very rapidly. I would have thought of a safer/easir way myself, albeit it would cost an extra penny.

3. This is a pure guess by me. I would assume that by de-enabling the LCD then any 'data' on the parallel bus will be ignored.
When writing to LCD the PIC output will comfortabley 'override' the effect of those two resistors.
As far as ADC is concerned - making PIC input (and obv the LCD will be input) then ADCing is OK , perhaps a little correction is needed due to loading but the 2 x 1k65 are a low value (unusual value too, any reason given?)
 

obroni

Member
They are claims, but the milestag system (what it is called) is in use by quite a few people and on various posts in forums, it is quite clear that these features do exist and work.

1. Yeah I know, the others I can sort of see how they might work, but this one really has me baffled. I might try contacting the guy behind it to see if he can shed any light.

2. So your saying if I issue a "low x" command and then read the port it should work even though when IR the detector is not connected, or does this work since the low command changes the impedance on the pin on the picaxe chip. What way would you think is simpler, I am open for suggestions.

3. In a forum post (http://www.laserforums.com/forum/archive/index.php/t-3048.html&) he suggests that a value between 1.65k - 2K is fine. But no explanation why these values are so important, apart from them being the same of course. I might try contacting him about this as well.

Thanks for your input.

EDIT: ps. For question 2, Would something like a 100k resistor pull down resistor help, or would that interfere with the data signal coming out the IR detector?
 
Last edited:

Dippy

Moderator
Re: 2.

Well, keep in mind this is merely a suggestion.....

In a compiled language you can make Port.pins as Inputs or Outputs and highs and lows much faster than PICAXE.
So, my caveat here is I'm NOT sure if this is safe with PICAXE.

The theory goes...
1. A pin when set to Input mode is floating.
2. It's impedance is so high that ambient electrical fields can affect the voltage of that pin.
3. Also the pin has some capacitance, so if you charge or discharge the capacitance charge then the status will remain on that pin briefly until it starts floating again.

So,
1. Make the pin an Output.
2. Set the Port.pin to 0
3. Make the pin an input.
4. Read the port.pin status.

e.g.
Output(Portb.0)
portb.0 = 0
Input(portb.0)
MyVar = portb.0 (oops)

If Portb.0 = 0 then the pin is unconnected or being held at 0V
If Portb.0 = 1 then the pin is being held at 5V i.e. it is connected with no I/R Data.

The same exercise can be done inversely to check the opposite status.

This could be used to see if the IR Module is connected AND data present.

HOWEVER, with a compiler with a PIC @ 20MHz the above can be accomplished in a few microseconds and is safe.

I am simply NOT SURE if damage would occur in PICAXE BASIC as it means potentially creating a near short-circuit for over 250 microseconds.

Personally, if I were a novice I would go for a simple pull-down as you have suggested and simply check for a device connected but with no data.

The value you suggest is probably OK. I would ALWAYS suggest to people to READ the actual IR device DATA SHEET to see what pull-ups, loads or whatever are specified - never guess unless you are experienced.

I wouldn't get too carried away doing a check that is rarely needed - though having things go peep and saying "Fault!" certainly impresses the girls.



Can't comment on the rest - don't have the time, sorry.
 
Last edited:

obroni

Member
Thanks, that really helps. I will look into the pulldown resistor idea and give the datasheets a look.

The check is quite important. Like the circuit I linked in my first post, I am making laser tag guns. Without the check, nothing stops people "accidentally" unplugging the sensors and thus becoming un-shootable.

Once again thanks for your help.
 

Dippy

Moderator
PS. Obviously I don't know what other discretes etc are on the IR sensor sub-board......
maybe it has a resistor...?
 
Top