Pages: [1]   Go Down
Author Topic: Simplest way of providing 50khz clock pulse?  (Read 641 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 434
Posts: 23596
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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.

Peoples Republic of Cantabrigia
Offline Offline
God Member
*****
Karma: 6
Posts: 691
Arduino happiness
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Sr. Member
****
Karma: 19
Posts: 486
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here's the simplest way I can think of:

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

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16459
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here's the simplest way I can think of:

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

Lefty
Logged

Montreal
Offline Offline
Edison Member
*
Karma: 22
Posts: 2483
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 434
Posts: 23596
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

With this tho, your code cannot do anything else

Code:
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.
Logged

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.

Earth
Offline Offline
Edison Member
*
Karma: 41
Posts: 1382
My browser no longer is binding static IP, Floating is the way to go.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Earth
Offline Offline
Edison Member
*
Karma: 41
Posts: 1382
My browser no longer is binding static IP, Floating is the way to go.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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









« Last Edit: April 12, 2013, 11:49:56 am by sonnyyu » Logged

Pages: [1]   Go Up
Jump to: