Tick generator function

Hi, Simple and quick question? How do I create a TickGenerator function that generates ticks every 10ms? Or is there an equivalent in some arduino library? Thank you

What exactly do you mean by "Tick" and how do you want to output it? How precise does it have to be?

You might try a simple approach like this and see if it is sufficient

loop()
{
    digitalWrite(outPin, HIGH);
    digitalWrite(outPin, LOW);
    delay(10);
}

Yeah that's an idea, but the problem is, I'm handling a compass module that communicates via an RS232 interface. When I downloaded the example code from the website, I found out that they're counting the ticks and telling the µC to send a command only if ticks have reached a certain value. So I guess i need to count the ticks. ? Sorry I'm not very familiar with Rs232 communication, I'm just starting to apprehend it.

Here I snatched a little parcel of the code where they're using this ticks() function...

switch(mStep)
{
case 1:
{
// the compents we are requesting, preceded by the
// number of...
UInt8 pkt[kDataCount + 1];
// ...components being requested
pkt[0] = kDataCount;
pkt[1] = CommProtocol::kHeading;
pkt[2] = CommProtocol::kPAngle;
pkt[3] = CommProtocol::kRAngle;
SendComm(CommProtocol::kSetDataComponents, pkt, kDataCount + 1);
// Ticks is a timer function. 1 tick = 10msec.
mTime = Ticks() + 100; // Taking a sample in 1s.
mStep++; // go to next step of process
break;
}
case 2:
{
// Ticks is a timer function. 1 tick = 10msec.
if(Ticks() > mTime)
{
// tell the unit to take a sample
SendComm(CommProtocol::kGetData);
mTime = Ticks() + 100; // take a sample every
// second
mStep++;
}
break;
}
case 3:
{
// Ticks is a timer function. 1 tick = 10msec.
if(Ticks() > mResponseTime)
{
Message("No response from the unit. Check connection and try again\r\n");
mStep = 0;
}
break;
}
default:
break;
}

By the look of that code, ticks is just a function to get the time since the Arduino started, like millis, but ticks returns increments of 10ms rather than 1ms as millis does. It's likely just a wrapper around millis in fact.

In this context, it's being used to provide a delay between telling the compass what parameters you want and then reading them. The delay is to allow the compass enough time to process the previous transmission before you send the next. If your application is simple enough, you could just use delay instead, but this example is trying to allow the arduino the opportunity to do other stuff while waiting for the compass. Check the blinkwithoutdelay tutorial for a simpler example.

What exactly is it you are trying to do? Why do you not use the Ticks() implementation that already exists?

They didn't implement the source code for this particular function the lazy bastards :D They're putting it there but it's up to me to create a header with the function :D

Isn't it simply millis () / 10 ?

I'll try and keep you posted

1°/ millis()/10 2°/blinkwithoutdelay

Thanks^^