Author Topic: Building a two channel counter - problems when using two channels but not one.  (Read 1135 times)

0 Members and 1 Guest are viewing this topic.

Offline threephase03Topic starter

  • Contributor
  • Posts: 23
  • Country: au

Hi All

I'm building a two-channel counter which counts pulses from an energy meter. I'm using One Teensy 3.6 for control & comms & Two Teensy 3.5 as the counters. The system works fine when I am counting one channel at a time but when I connect two they interfere with each other and don't deliver the correct results 

the counters output 3V and as it gets pulsed it interrupts a pin and adds 1 to the counter

Is there anything obvious I am overlooking?

Thanks for taking a look


 

 
 

Offline Signal32

  • Frequent Contributor
  • **
  • Posts: 251
  • Country: us
Why not just use a single teensy to do all the counting & comm ?

I will assume there is a valid reason for that. Questions to give more details about problem:
 - Have you tried running the teensies at 3.5v - it may be a signal level issue.
 - What is each teensy doing, who is keeping track of the pulse count - master Teensy 3.6 or Teensy 3.5 ?
 - Is the output from the slave teensy 3.5 always good and the comm Teensy 3.6 messes up - where does the counts get corrupted ?
 - How do the counts get corrupted, what issue are you seeing - what is expected result ?
 

Online rstofer

  • Super Contributor
  • ***
  • Posts: 9963
  • Country: us
I'm just guessing that the problem is in the center Teensy as it seems to be getting serial messages from the two clients.  What you didn't say is whether you have proper interrupt driven IO going into queues or were trying to do it with polling which is likely to fail.

Post your code for the master and the slave.
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 5570
  • Country: va
With a single Teensy 3.5/3.6 you have to be able to count 2 channels at 10000 pulses per second and do the communication in parallel without a single count lost.
Rethink your design..
PS: for example with 2 interrupts for channel A and B, rising or falling edges of the pulses increment ie. 64bit counters counter_A and counter_B inside an ISR_A and ISR_B (interrupt service routine).
In parallel you can do what you want.
« Last Edit: September 01, 2018, 10:44:11 am by imo »
Readers discretion is advised..
 

Offline threephase03Topic starter

  • Contributor
  • Posts: 23
  • Country: au
Sorry for the late reply, i had to start a different project and only just getting back to this one.
I know when the pulses are going to come. So I'm not communicating with it while its counting.

I'm going to try and put opto's in to isolate each board from each other and see how that goes.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf