For my scoreboard project I am using shiftOut() to send the score to display to my shift registers. The scoreboard works fine, but I want to learn how to use my oscilloscope. I thought a cool thing to look for would be how the clock and data signals work together. I know that I have to use a trigger to see this, so here is what I have tried.
DC Coupling
Trigger voltage on the data channel (channel 2) set to +1.5V. Ard pin 10 for me.
Trigger on rising edge, data channel
Channel 1 is for the clock. Ard pin 11.
5v/div
Time division? I've tried many, but it just seems unreliable. Maybe 50ms per div???
If I understand how it works, the arduino turns the clock and data on to send to the shift register when a change is needed. It doesn't keep refreshing and continually send the same data while the score is displayed. At least that is what my probing around has showed me. So it's like "score change? Send the updated score one time to the shift registers. Turn the clock on, send the data, turn the clock off and stop sending data". The new score is shown until the next score change. So I would only expect to see data on my scope when the score changes, so I would need a trigger. Did I get that right?
So, the problem is, I have not had much luck getting the data on the scope. I was wondering if someone could tell me what other settings I might need to look at. I have a Rigol DS1054, if that matters. I have seen the traces a couple of times, but when I went to change the score again, even with the same settings, I didn't see the trace. So I don't know if I don't have the scope set up correctly, or if I don't understand how the shiftOut() command works. I hope that makes sense.
Make sure your trigger is set to normal not auto. Auto triggers the scope anyway if no trigger signal has been received for a certain period of time.
If I understand how it works, the arduino turns the clock and data on to send to the shift register when a change is needed. It doesn't keep refreshing and continually send the same data while the score is displayed. At least that is what my probing around has showed me.
It depends on you hardware, does it need refreshing because your displays are being multiplexed? I would expect to see that if it were the case.
However if you see that and it dosn't need multiplexing then it is your software that is at fault and as you rightly say you only need to send when something changes.
Oh boy. Dumb question. How do I know if I am multiplexing? Here's my code:
void DisplayFourDigitScore(int homescore, int guestscore) {
int homeOnesDigit = homescore % 10;
int homeTensDigit = (homescore - homeOnesDigit) / 10;
int guestOnesDigit = guestscore % 10;
int guestTensDigit = (guestscore - guestOnesDigit) / 10;
digitalWrite(latchPin, LOW);
// shift out the bits:
// visitors first
shiftOut(dataPin, clockPin, MSBFIRST, encodedSsd[guestOnesDigit]);
if(guestTensDigit==0) {
shiftOut(dataPin, clockPin, MSBFIRST, 0);
} else {
shiftOut(dataPin, clockPin, MSBFIRST, encodedSsd[guestTensDigit]);
}
// home team
shiftOut(dataPin, clockPin, MSBFIRST, encodedSsd[homeOnesDigit]);
if(homeTensDigit==0) {
shiftOut(dataPin, clockPin, MSBFIRST, 0);
} else {
shiftOut(dataPin, clockPin, MSBFIRST, encodedSsd[homeTensDigit]);
}
//take the latch pin high so the LEDs will light up:
digitalWrite(latchPin, HIGH);
}
I call this code each time the score changes. I have four shift registers, all chained together.
Yes, I forgot to mention that I did see that the normal mode for the trigger seemed to be the most reliable.
Again, the scoreboard works fine. I am just trying to learn how to use my scope on this. There's no fault that I am trying to track down (other than my understanding of how it all works!)
I'm trying to understand this better. Why would triggering on the clock be different/better than triggering on the data, since they both should start at the same time?
If two signals do indeed start at the same time, would it make a difference which one you trigger with?
“I'm trying to understand this better. Why would triggering on the clock be different/better than triggering on the data, since they both should start at the same time? “
Data is synchronized with the clock.
Data can have gaps and different patterns, hence triggering is hit and miss.
MrGibbage:
I'm trying to understand this better. Why would triggering on the clock be different/better than triggering on the data, since they both should start at the same time?
If the data's all zeroes, nothing might happen on the data line, but the clock is definitely going to
toggle when data is sent.
If you want to play with the 'scope and learn things, change the code to resend regularly, say every second,
much more productive!
I got it working! "Normal" was definitely the way the go. I had to set the trigger voltage closer to 3v. I reliably saw that if I set the trigger voltage down around 1.4v, it just wouldn't work. I could press the buttons to change the scores and nothing would happen. The scope said "waiting". If I set the scope on auto, sometimes I could see the spike, but of course it would disappear too fast to read anything. But when I would put it to normal, nothing would happen at the low trigger voltage. But when I raised it up to around 3v, it worked perfectly. Weird, huh?
Trigger controls often have hysteresis, to reduce noise susceptibility, so the nominal trigger voltage is a
vague guide until hysteresis is dialed back to 0.