Go Down

Topic: Simplest way of providing 50khz clock pulse? (Read 841 times) previous topic - next topic

saitir

Hi

I'm putting together a prototype that will use 4442 smart cards.  They require a 50khz clock.

Unless I'm missing something (entirely possible) there's no practical way to get a clock feed from the arduino is there?

This would leave me to provide a separate clock circuit to run the device.  But I can always hope I missed something so I can simplify my circuit!

Any hints or help would be appreciated.

CrossRoads

That's a pulse every 20microseconds, pretty quick.
You can program one of the fuses to output the system clock on one of the pins, then use a divide by counter to get it lower.
Or, try PWM and adjust the frequency.

Google "arduino pwm frequency", the first 2 hits have PWM frequency adjusting info.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Constantin

Another simple option is to use a CMOS 555 chip to provide the square wave in case you don't want to burden the Arduino with providing it. Similarly, a Schmitt-trigger chip can provide a very nice square wave using just a resistor and a capacitor. Either option doesn't cost much and provides a reliable square wave signal, allowing your arduino to focus on other tasks.

TanHadron

Here's the simplest way I can think of:

Code: [Select]
for (;;)
{
  digitalWrite(outputPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(outputPin, LOW);
  delayMicroseconds(10);
}

retrolefty


Here's the simplest way I can think of:

Code: [Select]
for (;;)
{
 digitalWrite(outputPin, HIGH);
 delayMicroseconds(10);
 digitalWrite(outputPin, LOW);
 delayMicroseconds(10);
}


I suspect you might be surprised at the actual resulting frequency using that method. As digitalWrite() statement itself takes some non trivial time to execute plus the looping function 'overhead' time will result in slower operation. How much slower should be a real eye opener for you.  ;)

Lefty

Magician

You may try TimerOne library, it supports microseconds. Or, as it suggested, tweak PWM frequency up

CrossRoads

With this tho, your code cannot do anything else

Code: [Select]

for (;;)
{
  digitalWrite(outputPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(outputPin, LOW);
  delayMicroseconds(10);
}

At 50 KHz, that's 320 16 MHz clock cycles/20uS period, so your software would be pretty tied up anyway.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

sonnyyu

Did you want try this?

Opensource Smartcard access lib for Arduino

*Smartcard access lib for Arduino based boards connected directly to a smartcard.
*Currently it is possible to communicate with a smartcard directly connected to a Arduino board or connected via a TDA8024T (or compatible chips. e.g. DS8024).
*Support class for SLE4432 / SLE4442 / SLE4441 and SLE4440 compatible sychron smartcards.

saitir

Thanks all for the feedback.

Extra special thanks to Sonyuu and Crossroads who understood my gibberish most directly!

Not sure how I missed the library on sourceforge, I would have sworn I'd tried every conceivable search term to avoid having to write this myself.

Cheers.

sonnyyu

#9
Apr 12, 2013, 06:46 pm Last Edit: Apr 12, 2013, 06:49 pm by sonnyyu Reason: 1
Quote
I would have sworn I'd tried every conceivable search term to avoid having to write this myself.


You might be able to prove the search skill for future;-

1. buy or browse from library  for general search book

i. Google Power Search, It looks good.  but I never have chance to read it.
ii.Google Hacks: Tips & Tools for Finding and Using the World's Information, I read this one, I learn a lot from it.
iii.How to Find Out Anything: From Extreme Google Searches to Scouring Government Documents, a Guide to Uncovering Anything About Everyone and Everything, the title might be too appealing to be true, I guess if I read it, first testing case will be search everything of author himself.
...

2. Search engine book

i. Google's PageRank and Beyond: The Science of Search Engine Rankings
ii. Information Retrieval: Implementing and Evaluating Search Engines
iii.Understanding Search Engines: Mathematical Modeling and Text Retrieval
...

I read some, understand some, have no clue some, some become such great sleep aid.

3. Use Search engine to help to learn how to search

You might find out a lot of the content of above books in web, all you need is Google.

after your learning, you should be easily understand when is case using  arduino shield, "arduino shield", arduino -shield...

I use Smartcard access lib for Arduino before, since I do not have direct connection ID1 adapter on hand (I know I could destruct smartcard USB reader to make one), I make a work a round by convert SLE card into ID0 (sim card size, I do have access ID1/ID0 cutting machine) then use ID0 adapter connect with Arduino.

Sample ID0 adapter:
https://www.sparkfun.com/products/573

I did get link of Smartcard access lib for Arduino by Google to post here, I found Google is faster than look up note. I leave search term of Smartcard access lib for Arduino for your home work.


BTW. even modern search engine support auto spell correct, auto complete... feature, you might push it too hard by spelling sonnyyu as Sonyuu.  :smiley-red:










Go Up