Simplest way of providing 50khz clock pulse?

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.

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.

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.

Here's the simplest way I can think of:

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

TanHadron:
Here's the simplest way I can think of:

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. :wink:

Lefty

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

With this tho, your code cannot do anything else

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.

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.

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.

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.
...

  1. 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.

  1. 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:

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. :blush: