If you're trying to shift at any decent frequency (which would be
desirable for a smooth crossfade event) then I would not use 'digitalwrite'
as it is an arduino function which takes a lot of processor time to simply
change an I/O to high or low logic level. Hardware SPI is #1, but I found
that a little difficult to use when I began programming my ESP32 nixie
projects in the arduino framework. I eventually figured out how to do it
with good results in software.
I'll share a little snippet of my code below that I've written for several
ESP32 based nixie clocks that also have crossfading. This should give you
some insight into using the fastest possible software based bitbanging
routines to toggle I/Os and drive your HV shift registers.
The first blocks establish the GPIOs I intend to use to drive the HV shift
registers (through a 40109 level shifter of course).
The senddata() function is the actual bitbang sequence which is being run
at several kHz using an interrupt service routine. This code in particular
is driving two HV shift registers which are 32 bits each, hence the for
loop spanning from i = 63 to i >= 0.
The "IRAM_ATTR" flag means that the compiled code for this function will be
placed in the Internal RAM (IRAM) of the ESP32, which is much faster than
storing it in the main flash. I would recommend doing some reading and
trying several online examples of ESP32 interrupt service routines. It is
essential for getting display routines (such as bitbanging) to run quickly
enough for good crossfading results.
"
#define GPIO22_H (GPIO_REG_WRITE(GPIO_OUT_W1TS_REG,
1<<22))#define GPIO22_L (GPIO_REG_WRITE(GPIO_OUT_W1TC_REG,
1<<22))#define GPIO22(x) ((x)?GPIO22_H:GPIO22_L) //HV Driver
Blank (GPIO22)#define GPIO5_H
(GPIO_REG_WRITE(GPIO_OUT_W1TS_REG, 1<<5))#define GPIO5_L
(GPIO_REG_WRITE(GPIO_OUT_W1TC_REG, 1<<5))#define GPIO5(x)
((x)?GPIO5_H:GPIO5_L) //HV Driver Latch Enable (GPIO5)#define GPIO18_H
(GPIO_REG_WRITE(GPIO_OUT_W1TS_REG, 1<<18))#define GPIO18_L
(GPIO_REG_WRITE(GPIO_OUT_W1TC_REG, 1<<18))#define GPIO18(x)
((x)?GPIO18_H:GPIO18_L) //HV Driver Clock (GPIO18)#define GPIO23_H
(GPIO_REG_WRITE(GPIO_OUT_W1TS_REG, 1<<23))#define GPIO23_L
(GPIO_REG_WRITE(GPIO_OUT_W1TC_REG, 1<<23))#define GPIO23(x)
((x)?GPIO23_H:GPIO23_L) //HV Driver Data (GPIO23)
...
void IRAM_ATTR senddata() { for (int i = 63;i >=0 ;i--) {
GPIO18_H; if (outputbuffer[i] == 1) { GPIO23_H;
} else { GPIO23_L; } GPIO18_L;
}GPIO5_H;GPIO5_H;GPIO5_L;GPIO5_L;}
"
On Wed, Jul 22, 2020 at 6:08 PM Paul Andrews <[email protected]> wrote:
> There is a 32 bit shift out, at least on ESP platforms.
>
> You aren’t limited to specific pins on the ESP8266
>
> I am pretty sure that for these chips you should move this line
>
> digitalWrite(LEpin, LOW);
>
>
> To just before this line:
>
> digitalWrite(LEpin, HIGH);
>
>
>
> On Jul 22, 2020, at 10:28 AM, Richard Scales <[email protected]>
> wrote:
>
>
>
> For the SPI I have the following in my sketch:
>
> #include <SPI.h>
>
> In setup:
>
> // set up SPI
> SPI.begin();
> SPI.setFrequency(100000);
> SPI.setBitOrder(MSBFIRST);
> SPI.setDataMode(SPI_MODE1);
> //set outputs for SPI
> pinMode(LEpin, OUTPUT);
>
>
> Then, I have the following code that, in my case, is writing two 32 bit
> variables ( j and k ) out to the shift registers via SPI:
>
> //SPI transfer code
>
> digitalWrite(LEpin, LOW);
>
>
>
> //send K out
> SPI.transfer((k >> 24) & 0xff);
> SPI.transfer((k >> 16) & 0xff);
> SPI.transfer((k >> 8) & 0xff);
> SPI.transfer(k & 0xff);
>
> //send J out
> SPI.transfer((j >> 24) & 0xff);
> SPI.transfer((j >> 16) & 0xff);
> SPI.transfer((j >> 8) & 0xff);
> SPI.transfer(j & 0xff);
>
>
> digitalWrite(LEpin, HIGH);
>
>
> There may well be a 32 bit Spi transfer but I was modifying older shiftout
> based code so stuck with what I was doing previously, YMMV.
>
>
> On a Wemos D1, when using SPI, I believe that you are tied to using:
>
> D5 for Clock
> D6 for Strobe
> D7 for Data
>
> I also run the HV5622's as 12V logic levels (keeping within spec) by using
> CD40109 level shifters, it all works really well.
>
> Please let us know how you get on.
>
> - Richard
>
>
>
> On Wednesday, 22 July 2020 08:38:47 UTC+1, Owen Crawford wrote:
>>
>> Hi Richard,
>>
>> You mentioned you have a working solution to digit fading?
>> I am pretty much in the position with designing a Nixie clock using the
>> HV5622 chips. I have worked out most of the PCB design and got a few
>> prototypes boards made up.
>> The HV5622 chips are in series and I've managed to make up some code in
>> Arduino IDE and can control individual pins/digits using ShiftOut() which
>> is inherently a bit slow with moving data to the registers.
>> I made up a fade table to quickly transition back and forth between the
>> previous and next digit to give the illusion of cross-fading.
>> This worked well for the most part, until I have more than 1 digit
>> fading, then the latency starts to become more noticeable and the digits
>> star to flicker in transition.
>> After countless hours of reading, SPI seems to be the way to go as it's
>> way faster to shift data out, however I am still in the middle of working
>> out how to use SPI with the HV5622 registers and Arduino as I'm just
>> getting random digits appearing all over the place.
>> I guess the next step after that was working out how to cross fade
>> digits. Would you be so kind with sharing what you came up with? Better
>> than trying to re-invent the wheel :)
>>
>> Thank you.
>>
>> / Owen
>>
>> On Sunday, 3 May 2020 at 18:06:15 UTC+10 Dekatron42 wrote:
>>
>>> There's another way of dimming/fading described in this thread with
>>> source code on Github - not mine, just remembered it.
>>>
>>>
>>> https://groups.google.com/forum/#!searchin/neonixie-l/fading$20table%7Csort:date/neonixie-l/bh7kymv2xQA/MogsmOnHAgAJ
>>>
>>> /Martin
>>>
>> --
> You received this message because you are subscribed to a topic in the
> Google Groups "neonixie-l" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/neonixie-l/UWcm5_T2868/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/neonixie-l/e514d49d-6a36-4042-a5bb-fc1efdd11d11o%40googlegroups.com
> <https://groups.google.com/d/msgid/neonixie-l/e514d49d-6a36-4042-a5bb-fc1efdd11d11o%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> --
> You received this message because you are subscribed to the Google Groups
> "neonixie-l" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/neonixie-l/83799903-10B7-4851-ADCB-45BD1501C4B5%40gmail.com
> <https://groups.google.com/d/msgid/neonixie-l/83799903-10B7-4851-ADCB-45BD1501C4B5%40gmail.com?utm_medium=email&utm_source=footer>
> .
>
--
You received this message because you are subscribed to the Google Groups
"neonixie-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web, visit
https://groups.google.com/d/msgid/neonixie-l/CALcVLK%2BvJkL4OkNaGsgvEuLkZm_7QzPMMqAqYGoarK5x7u-NyA%40mail.gmail.com.