How to implement 10...
 
Notifications
Clear all

How to implement 100 null pixels?

68 Posts
11 Users
0 Reactions
10.8 K Views
Posts: 105
(@pakeonoahu)
Estimable Member
Joined: 11 years ago
// THIS CODE IS FOR USE WITH THE 74HCT125 IC ONLY
// THE 74HCT126 USES A DIFFERENT CODE

void setup() {

//****** PIXEL SETUP ***
int Output_1 = <number of pixels on output 1>; ; // Replace < --- > with the number of pixels connected to output 1.
int Output_2 = <number of pixels on output 2>; // Replace < --- > with the number of pixels connected to output 2.

//*** PORTS ***
DDRD &= ~(1 << DDD3) & ~(1 << DDD5); // set PD3 & PD5 as inputs.
DDRB |= (1 << DDB1) | (1 << DDB2); // set PB1 & PB2 as outputs.
PORTB |= (1 << PORTB1) | (1 << PORTB2); // set PB1 & PB2 high.

//*** INTERRUPT 1 ***
EICRA = 0; // clear EICRA register.
EICRA |= (1 << ISC10) | (1 << ISC11); // set interrupt on rising.
EIMSK |= (1 << INT1); // enable interrupt.

//*** TIMER 2 *** 
TCCR2A = 0; // clear TCCR2A register.
TCCR2B = 0; // clear TCCR2B register.
TIMSK2 = (1 << OCIE2A); // enable interrupt.
OCR2A = 255; // set OCR2A (count to) value about 280uS inc int.

//*** TIMER 1 ******
TCCR1A = 0; // clear TCCR1A register.
TCCR1A |= (1 << COM1B1) | (1 << COM1A1); // set OCR1A\B WGM to set low on compare match.
TCCR1B = 0; // clear TCCR1B register.
TCCR1B |= (1 << CS11) | (1 << CS12) | (1 << WGM12); // set ext input, CTC mode & falling trigger.
TCNT1 = 0; // set TCNT1 counter register to zero.
OCR1B = (Output_1 * 24) - 1; // set OCR1B (1st count to value).
OCR1A = ((Output_2 + Output_1) * 24) - 1; // set OCR1A (2nd count to value).
}
//****** ISR interrupt 1 **
ISR (INT1_vect) {
  TCCR2B |= (1 << CS21); // start timer 2 & set prescale to 1/8 clock.
  TCNT2 = 0; // reset timer 2 counter to zero.
  OCR2A = 255; // set OCR2A (count to) value about 280uS inc int.
}
//*** ISR timer 2 ******
ISR (TIMER2_COMPA_vect) {
TCCR2B = 0; // stop timer 2.
TCNT1 = 0; // reset timer 1 counter to zero.
TCCR1A |= (1 << COM1B0) | (1 << COM1A0); // timer 1 WGM to set high on compare match.
TCCR1C |= (1 << FOC1A) | (1 << FOC1B); // timer 1 force compare match (set outputs low).
TCCR1A &= ~(1 << COM1B0) & ~(1 << COM1A0); // timer 1 WGM to set low on compare match.
}

void loop() {
}

updated code from Barnabybear


Reply
Posts: 6728
(@p-short)
Illustrious Member
Joined: 19 years ago

It's not too surprising that the WS2811 isn't too happy with 3V high pulses on it's input. It could go either way, but I wouldn't trust it to have reliable operation.

The Atmega should work with it's power input down as low as 2.7V per spec, so 4.1V is good for the Atmega per se. The ACT/HCT parts are not needed here, they're only relevant when the gates would be powered off 5V but their input signals don't get above 5V (from 3.3V micro's or regular TTL/LSTTL/ALSTTL parts).


Reply
Posts: 105
(@pakeonoahu)
Estimable Member
Joined: 11 years ago
P. Short wrote:It's not too surprising that the WS2811 isn't too happy with 3V high pulses on it's input. It could go either way, but I wouldn't trust it to have reliable operation.

The Atmega should work with it's power input down as low as 2.7V per spec, so 4.1V is good for the Atmega per se. The ACT/HCT parts are not needed here, they're only relevant when the gates would be powered off 5V but their input signals don't get above 5V (from 3.3V micro's or regular TTL/LSTTL/ALSTTL parts).

More interestingly I ran the Nano with 12v on Vin, the 5v pin produced 5V, the pixels acted the same like 74125 was running at 4.1v, something is leaking over from the Nano, adding a 100uF capacitor to it not helping, I also have .1uf cap next to the VCC of the 74125, powering the 74125 without using the 5V out from Nano has no issue, the nano's regulator actually is an AMS1117 5.0 rated for 1 amp, I don't think the whole circuit is pulling that much current, my solution to run it on 12v pixel will have to add a dc-dc buck converter(or 7805 regulator) for 5V.


Reply
Page 14 / 14
Share: