Go Down

Topic: HDSP 2111 problem (Read 1 time) previous topic - next topic

theSnark

Hello,

This is is my first post here, and I thought I'd drop in with a nice problem(well not really).

Let me start by saying that im quite sure it must be something I am doing wrong. So if someone can poke a hole in what I've made then that be great.

What I am trying to do is hook up a couple of HDSP 2111 display to the arduino, with the intent to use this as a NAV/AP display(Nav1, Nav2, HDG/CRS, ALT, VS) for Flightsimulator(X, 2004).

I followed the NYC resistor tutorial and the Jos van Dijk tutorial:

http://www.nycresistor.com/2010/05/30/working-with-the-hdsp-2111/
http://www.josvandijken.nl/elektronica_HP_HDSP-2111.php

From this onward I added a HCT595N serial-in parallel-out shiftregister.

So far so good. Then I tried hooking up a serial connection via python(with pyserial and fsuipc, python extension from the SDK). This started given trouble(filled up block chars in the display).

So, to confirm the output was OK I hooked up the shiftregister to a bank of 8 LED's. As it turned out all the LED lit up as soon as I tried to display any of the serial data. Then I tried to show just a single character(pre defined) if any came in on the serial connection. The Arduino LED showed inbound activity but alas, again all the LED's burned bright.

So, just to make sure I wasnt crazy(heh..) I decided to do a simple loop to 255 and shift that out to the LED's. This worked fine, as long as I DONT do it in the loop() function(it works in setup(), or start() etc.).

I was a bit stumped since it didnt make any sense, to confirm it wasnt something in the code I copied it into its own script and compiled/uploaded that one. This didnt solve the problem. So right now im a bit stuck. I am sure it must be something that I am doing since the original example(josvandijk link) that I used worked perfectly(scrolling text). Right now I can only show a frequency or a heading in the setup() code. Any update during the loop() will either blank the display or show random characters.

This is the code I am using to control the display:

Code: [Select]

/*
         Demo Code for HDSP-2111
Jos van Dijken
www.josvandijken.nl
28 april 2012

Based on the code from:
Matt Joyce < matt at nycresistor.com >
Mark Tabry
*/

int RST   = A0;
int WR    = A1;
int CE    = 10;
int RD    = 11;
int AD0   = A2;
int AD1   = A3;
int AD2   = A4;
int AD3   = A5;
int DS    = 0; //shiftregister datapin
int ST_CP = 1; //shiftregister storageclock(latch)
int SH_CP = 2; //shiftregister shiftclock(data polling)

void setup()
{
  pinMode(RST    , OUTPUT); //reset pin, init on startup
  pinMode(WR     , OUTPUT);
  pinMode(CE     , OUTPUT);
  pinMode(RD     , OUTPUT);
  pinMode(AD0    , OUTPUT); // data register selection // these 4 pins allow one to select a data register.
  pinMode(AD1    , OUTPUT); // data register selection
  pinMode(AD2    , OUTPUT); // data register selection
  pinMode(AD3    , OUTPUT); // data register selection
  pinMode(DS, OUTPUT); //shift register serial in
  pinMode(ST_CP, OUTPUT); //shift register storage pin(latch)
  pinMode(SH_CP, OUTPUT); //shift register clock pin(clock)
  digitalWrite(CE, HIGH); // chip enable, go low before wr. go high after wr
  digitalWrite(WR, HIGH); // write enable, go low to start write, go high when done.
  resetDisplay();
  delay(1000);
  start();
  Serial.begin(9600);

}

void resetDisplay()
{
  digitalWrite(RST, LOW);
  delayMicroseconds(1);
  digitalWrite(RST,HIGH);
  delayMicroseconds(150);
  digitalWrite(AD3, HIGH);
}

void writeDisplay(char *input)
{
  for (int i=0; i<8; i++)
  {
    // below bit(AD0,1,2) is setting the correct display character index(i)
    digitalWrite(AD0, (1&i)!=0?HIGH:LOW); // bitwise AND[&] comparator(meaning both bits of 1 and i needs to be 1 to give true(set bit in result as 1).
    digitalWrite(AD1, (2&i)!=0?HIGH:LOW);
    digitalWrite(AD2, (4&i)!=0?HIGH:LOW);
    delay(1);
    digitalWrite(CE, LOW);
    delay(1);
    digitalWrite(WR, LOW);
    delay(1);
    digitalWrite(ST_CP, LOW);
    delay(1); //allow the display to retrieve the values set to the D pins(PORTD)
    shiftOut(DS, SH_CP, MSBFIRST, input[i]);
    delay(1);
    digitalWrite(ST_CP, HIGH);
    delay(1);
    digitalWrite(WR, HIGH);
    delay(1);
    digitalWrite(CE, HIGH);
    delay(100);
  }
}

void start()
{
  char intro[] = "360  310";
  writeDisplay(intro);
  delay(100);
 
  for(int i = 0; i < 256; i++)
  {
    Serial.print(i);
    digitalWrite(ST_CP, LOW);
    delay(1); //allow the display to retrieve the values set to the D pins(PORTD)
    shiftOut(DS, SH_CP, MSBFIRST, i);
    delay(1);
    digitalWrite(ST_CP, HIGH);
    delay(100);
  }
}

void loop()
{
   
}


And this is the code I am using for the test(copy'ed from other file).

Code: [Select]

int DS    = 0; //shiftregister datapin
int ST_CP = 1; //shiftregister storageclock(latch)
int SH_CP = 2; //shiftregister shiftclock(data polling)


void setup()
{
  pinMode(DS, OUTPUT); //shift register serial in
  pinMode(ST_CP, OUTPUT); //shift register storage pin(latch)
  pinMode(SH_CP, OUTPUT); //shift register clock pin(clock)
  Serial.begin(9600);
  start();
}

void start()
{
  for(int i = 0; i < 256; i++)
  {
    Serial.print(i);
    digitalWrite(ST_CP, LOW);
    delay(1); //allow the display to retrieve the values set to the D pins(PORTD)
    shiftOut(DS, SH_CP, MSBFIRST, i);
    delay(1);
    digitalWrite(ST_CP, HIGH);
    delay(100);
  } 
}

void loop()
{
 
}


This is the schematic created in eagle:




And a photo of the current setup. The only thing changed are that the wite and orange wires now lead to the red LED's.



I have been trying to figure out what is wrong for the last 2 days, and im quite sure im missing something.

I hope the image size doesnt exceed a limit, I tried looking up the rules for that. Alas. If it is a problem I will fix it, got to go in a few minutes though.

I am using a Arduino Duemilanove.

MarkT

The Serial interface is hardwired to use pins 0 and 1 - but these are also connected to your shift register - thus it will do strange things if using the USB/serial interface which also talks to pins 0 and 1.
[ I won't respond to messages, use the forum please ]

theSnark

Thanks! That sounds remarkably simple to fix.

I actually read about the pins and noted the TX and RX signs next to them but discarded it since I figured setting them up as digital outputs would overwrite those properties. I shall try this later today!

theSnark

I tested it today and you are correct, it now works perfectly!

So, if port 0 to 7 can be set to digital output pins with PORTD would the same effect happend? Or is it some sort of lower level command that overrides the TX/RX function on those ports?

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy