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 support@ccsinfo.com

How to detect input - output signal
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
sonix
Guest







How to detect input - output signal
PostPosted: Thu Sep 27, 2007 3:18 am     Reply with quote

I have one signal that is "almost" like to square wave.
What i want to do is to detect when the signal is high and when low.

How to make this ?
Guest








PostPosted: Thu Sep 27, 2007 3:19 am     Reply with quote

forget to say that this signal last cca 1 second and the speed is 9600 b/s.
inservi



Joined: 13 May 2007
Posts: 128

View user's profile Send private message

PostPosted: Thu Sep 27, 2007 5:23 am     Reply with quote

Hello,

Can you give us the electrique voltage for low and high levels ?

dro.
_________________
in médio virtus
tom_hanks



Joined: 04 Apr 2007
Posts: 20

View user's profile Send private message

PostPosted: Thu Sep 27, 2007 9:31 am     Reply with quote

Assign this signal to interrupt pin...

use a timer according to the speed of the signal....

so when ever signal transit from high to low, ISR will set the flag to low....

1. with the help of while loop in main....you can reset the flag on going high...

2. or use a timer
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Thu Sep 27, 2007 1:38 pm     Reply with quote

Quote:

I have one signal that is "almost" like to square wave.
What i want to do is to detect when the signal is high and when low.
forget to say that this signal last cca 1 second and the speed is 9600 b/s.


It seems that you really are needing is to decode a data packet.
1) Are you able to freeze a frame with a scope?
2) If so, could you tell us the pulses amplitude?
3) And the width and level of the shortest pulses?


Humberto
sonix
Guest







PostPosted: Fri Sep 28, 2007 3:20 am     Reply with quote

1.) Can you give us the electrique voltage for low and high levels
- low level is 3.5 and high 4V.

2) Are you able to freeze a frame with a scope?
- the frame looks almost like "answer to select (ATS)" signal in chip cards and it contains the same bytes (long byte, checksum bytes etc.)
inservi



Joined: 13 May 2007
Posts: 128

View user's profile Send private message

PostPosted: Fri Sep 28, 2007 4:21 am     Reply with quote

Hello,

Most of the PIC (and probably all) have TTL/CMOS input as standard.
Have a look there : http://www.interfacebus.com/voltage_threshold.html

The treshold voltage is 1.5V then with low and high level between 3.5 and 4v, you can not detect the changing level in TTL mode. Some PIC have Triggered input with a different treshold level.

So there are two solutions one without hardware signal formating/adapting and one with hardware signal formating/adapting.

I can propose 2 solutions:

1 - Without hardware signal formating/adapting:
Use A/D converter if the converter is fast enough for you signal.
9600b/s require at least 9600 conversion by seconds (the double or triple
is probably more resonable) Ok, 30 000 / sec = 33µ sec/sampling.
That look to be difficult with a 16f877. but other PIC are quickest.
The A/D conversion look to be possible with the right PIC !

2 - With hardware signal formating/adapting :
use small electronic circuit for change level in the correct TTL range . That can be achieved with 3 resistors and one transistor ( and maybe only two resistors as voltage divider ).
I'm sure that some one can send a circuit sample for that. For me, it's a few haggling for find the right resistors value.

Personally, i prefer the second solution !

When the PIC can detect the electrical levels, you can start with software side.

Best regards,
dro.
_________________
in médio virtus
tom_hanks



Joined: 04 Apr 2007
Posts: 20

View user's profile Send private message

PostPosted: Fri Sep 28, 2007 6:03 am     Reply with quote

use a opamp in comparator mode...
for 3.5 v it should give u low voltage
and for high 4v it shoudl give u high logic at the output...

LMC7101 is best for this type of application
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Fri Sep 28, 2007 7:15 am     Reply with quote

How about a PIC like the 16F630 which has a built in comparator and reference voltage generator? I have never used it but a quick look at the datasheet seems promising.
_________________
The search for better is endless. Instead simply find very good and get the job done.
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Fri Sep 28, 2007 8:03 am     Reply with quote

Lets assume that the signal levels you are reading are out of TTL levels, unless you
are reading a signal like RS485.

1) From what device the signal is coming from?
2) How many wires are carrying such signals?
3) How did you determine the 9600 b/s speed.
4) Tell us the minimum measured width.

Humberto
inservi



Joined: 13 May 2007
Posts: 128

View user's profile Send private message

PostPosted: Fri Sep 28, 2007 8:32 am     Reply with quote

Hello,

SherpaDoug, you are right, that look to be a very good solution !

Quote:

As How about a PIC like the 16F630 which has a built in comparator and reference voltage generator? I have never used it but a quick look at the datasheet seems promising.


dro.
_________________
in médio virtus
Alanis



Joined: 28 Sep 2007
Posts: 13

View user's profile Send private message

PostPosted: Fri Sep 28, 2007 9:09 am     Reply with quote

1) From what device the signal is coming from?
- from embedded system based on prepaid cards.

2) How many wires are carrying such signals?
- one input - output

3) How did you determine the 9600 b/s speed.
- protocol. It could be 9600 or 19200. But 9600 used as test.

4) Tell us the minimum measured width.
- 2,2V
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Fri Sep 28, 2007 12:09 pm     Reply with quote

Quote:

2) How many wires are carrying such signals?
- one input - output

I can´t figure what do you mean
1 wire (bidirectional input/output) + Reference?
2 wires (1 Input + 1 output?)
3 wires (1 Input + 1 Output + Ref)

Quote:

4) Tell us the minimum measured width.

I mean, the shortest pulse time duration (in usec) that you can see or measure in the frame.
For 9600 bauds, the minimum width you will found should be 104usec and all other
wider pulses should be multiples of these.

What is the reference level used when you did the measurements?


Humberto
Alanis



Joined: 28 Sep 2007
Posts: 13

View user's profile Send private message

PostPosted: Sat Sep 29, 2007 3:00 am     Reply with quote

wire (bidirectional input/output) + Reference?
- thats the one.

the shortest pulse time duration (in usec)
- if i use freq of 3,5 MHZ the puls is cca 110 uS.
- if i use 5 MHz the puls is cca 82 us

Basically, its defined in ISO/IEC 7816-3 standard.
Is this what you mean ?
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Sat Sep 29, 2007 7:40 am     Reply with quote

Quote:

Basically, its defined in ISO/IEC 7816-3 standard.
Is this what you mean ?

Did you found THAT ISO Standard trying to respond my previous comments? Cool
ISO 7816-3 refer to Electronic Signals and Transmission Protocols for Smart Cards.
If you are trying to read a Smart Card (ISO 7816), simple answer: you can´t.
Unless you have enough skills/tools/knowledge to decipher complex cryptographic
algoritms, cryptogrphic protocols or both.

If you want to play with a Smart Card, you will find good info in some AN in the Microchip site.
If you want useful technical data you will find it in this link:

http://www.cardwerk.com/smartcards/smartcard_standard_ISO7816-3.aspx


Humberto
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 1, 2  Next
Page 1 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