Show Posts
Pages: [1] 2 3 4
1  Using Arduino / Sensors / Re: Seperate IC to Count Pulse Input? on: April 27, 2014, 11:35:42 am
EDIT:
This is the thread, http://forum.arduino.cc/index.php?topic=69358.0, I didn't re read it to see if there are any details but I know that's what he did because I helped off line with it.

______
Rob

Thanks Rob! It's quite an old thread, but I've posted there to see if the code could be made available.

I wonder if there are some small FPGAs that could do this.. or maybe it's overkill. I haven't done anything with an FPGA before, so excuse my ignorance.
2  Community / Exhibition / Gallery / Re: "The Brick" - All In One - Arduino Platform Compatible on: April 27, 2014, 11:32:39 am
@liudr

Would it be possible for you to share your Attiny84 counter with SPI firmware/code? I've got a need for something like that. I've done a counter on a Attiny85 with I2c, but for other reasons would need to move to an 84. Also, do you use an external crystal or the internal oscillator with the ATtiny84?

Thanks!
3  Using Arduino / Sensors / Re: Seperate IC to Count Pulse Input? on: April 26, 2014, 12:39:11 pm
I looked at some of those real time clocks as well..but if you need multiple counters at the same time, you'd have an i2c address conflict. Also,  I'm more interested in frequency measurement so I'd be nice if the IC was able to do most of the computing.

It would be great if a small single chip could take two or three inputs as counters or interrupts to count. And communicate via i2c or spi. Maybe attiny84? I might look into that
4  Using Arduino / Sensors / Re: Seperate IC to Count Pulse Input? on: April 25, 2014, 02:38:05 pm
Hey, I've been looking for a similar solution a separate IC that can count pulses and also calculate frequency..since you're already counting pulses and using timers..

Anyway, was looking for a ready made solution and found one chip the LS7366r which communicates via SPI. They're not cheap or very easy to come by.  I found a few breakout boards, but still pricey.

I opted to program an ATtiny85 and came up with a working solution that will send pulse information over I2c. The major problem is precision... If you want to use the 8bit timer/counter then you cannot use a crystal.  Regardless, I tried both an interrupt based method and count interrupts with a short ISR(PCINT) and with the 8bit counter. Lastly, to get better timer precision, you can tune it, but it's not ideal for me. I might try an ATtiny84 which has more pins free for crystal and counter. If anyone would like to collaborate or help or just test it on their setup, PM me.

I might try the crystal and pcint on the 85 and report back...need to buy a crystal

Thanks

5  Using Arduino / Microcontrollers / Re: Attiny85 Tiny Core - Override Timer1 Overflow Interrupt ISR with another one? on: March 11, 2014, 08:07:13 pm
Confirmed. I switched it over to Timer0 and I2C /USI is working ok.

Thanks!!

6  Using Arduino / Microcontrollers / Re: Attiny85 Tiny Core - Override Timer1 Overflow Interrupt ISR with another one? on: March 11, 2014, 07:25:29 pm

Thanks! I'm aware of this option, but maybe you can quickly answer this for me...will this affect the USI clock stuff if I move millis to Timer0?? I'm using USI for for I2C communication.
7  Using Arduino / Programming Questions / Re: Problem With Division, Types, and Casting on: March 11, 2014, 07:04:49 pm
This seems to work:

Code:
#define FCPU 8000000L

timerPeriodMicros = ((float)PrescalerVal/(float)FCPU)*(float)1000000L;//.125*PrescalerVal;
period = timerPeriodMicros * periodTicks;//period in microseconds//implicitly cast
return period;

But is there a cleaner or better solution? What's the best way to approach this?
8  Using Arduino / Programming Questions / Re: Problem With Division, Types, and Casting on: March 11, 2014, 06:43:11 pm
Prescaler Holds an integer value between 1 and 16384

Yes, I understand about Integer Division, but I have defined TimerPeriodMicros as a float. That allows decimals, to my understanding... Does implicit casting not work that way? Do I need to cast as float on the right hand side of the equation?

I guess I'm just thrown off. Also, I'd like to accomplish my math in one line versus two lines like above.
9  Using Arduino / Programming Questions / Re: Problem With Division, Types, and Casting on: March 11, 2014, 06:18:52 pm
Why? And what's the remedy?
10  Using Arduino / Microcontrollers / Attiny85 Tiny Core - Override Timer1 Overflow Interrupt ISR with another one? on: March 11, 2014, 06:11:11 pm
I'm implementing some code and I am not using millis() and micros() which take advantage of the existing Timer1 Overflow ISR in Wiring.C file.

I need to implement a different routine. Is there a smart way via code to override or reroute to my new ISR? Meaning without deleting or commenting things out in the Wiring.C file. I don't want to fuss with the core files, I just want my own routine on top.

For reference:
 Here' the compile error I'm getting when I use my ISR:
Quote
core.a(wiring.c.o): In function `__vector_4':
C:\Users\Me\Documents\Arduino\hardware\tiny\cores\tiny/wiring.c:78: multiple definition of `__vector_4'

Digging that up leads to : ISR(MILLISTIMER_OVF_vect)

Thanks!
11  Using Arduino / Programming Questions / Re: Converting and Integer Array into One Single Number!!? on: March 11, 2014, 05:59:01 pm
Hi,

would something like this work for you:

Code:
number=0;
exponent=5;
for (int i=1;i<=5;i++)
{
number = number+num[i]*(10^exponent);
exponent--;
}
12  Using Arduino / Programming Questions / Problem With Division, Types, and Casting on: March 11, 2014, 05:17:32 pm
Hi I'm writing some lower level code for an Attiny85 and have a CPP file that does the heavy lifting for the arduino. I'm using the Tiny Cores found on google code.

Anyway, I have simplified down my expression to the following to showcase where the problem is:

Code:
static volatile float timerPeriodMicros;
static volatile uint32_t Period;
static volatile uint16_t PrescalerVal;
#define FCPU 8000000
...

function GetPeriod(void)
{
TimerPeriodMicros = (PrescalerValue/FCPU) * 1000000; //returns zero always. It should return something like 512 or Timer1 Tick period
//Re-arranging the math to PrescalerValue*(1000000/FCPU) also fails
//Re-arranging the math to PrescalerValue*.125 works!
Period = TimerPeriodMicros * PeriodTicks;
return Period;
}

Any suggestions would be helpful!

Thanks!
13  Using Arduino / Microcontrollers / Re: Tuning Internal Oscillator of ATTiny85 - Hardware Setup for Two Way Serial? on: March 04, 2014, 11:24:41 pm
It appears to be working  smiley-cool ...Thanks Codingbadly for the Poor Man's Tuner code...

You are welcome.  I'm glad you got it working.

Have you considered using Tiny Tuner 2?


I'll give it a shot!...Briefly, what are the differences/advantages of Version 2?

Also, before I start digging deeper...what is Tiny Debug Knock Bang? Lastly, will the hardware setup above work for this tuner?
14  Using Arduino / Networking, Protocols, and Devices / Re: Need Help Getting I2C TinyWireS Slave code working in ATtiny85.. on: February 25, 2014, 03:45:00 pm
Well, the results seem inconsistent, but now I'm getting clean transfers when it's working...
Here's a updated screenshot.[click to enlarge]

Would you like me to zoom in on a specific part?

I am using Micros to capture some time.

Here's my ISR:
Code:
//PCINT Interrupt
ISR(PCINT_VECTOR)
{
  microsTemp = micros(); //get time first!
  if (ReadPinState()>0)//pin is high/rising edge
  {
   
    InterruptCount++;
    switch(InterruptCount)
    {
      case 1: t1=microsTemp;//start time
              counting=true;
              break;
      case 2: t2=microsTemp;//end time
              counting=false;
              InterruptCount=0;//reset count
              break;
      default:
              //InterruptCount=0;
              break;
    }

  }
}
15  Using Arduino / Microcontrollers / Re: ATtiny85 Counter/Timer0 Input for Frequency Capture on: February 25, 2014, 03:19:40 pm
I got it calibrated with the Poor Man's Tuner. Though I know each chip's results will be different mine is :
OSCCAL = 0x45;
Calibration steps are linked in my previous post/thread above.

Anyway, I added that line into my code and it's MUCH more accurate...Something I can live with. I'd like better, but this will do for now.

The problem I'm having now is some delays in getting the correct value that I'm getting with my I2C communication with another device. I'm sending the measured period to the master device...


Pages: [1] 2 3 4