HELP: Si570 Controller Code

I have been given this code to play with, at the moment it is working on a Arduino uno R3 but i will use a atmega1284p, The code is in the attachment below as too big.

In the code he comments about the "wire.h"

IMPORTANT, the wire.h is modified so that the internal pull up resisters are not enabled.
This is required to interface Arduino with the 3.3v Si570's I2C interface.

Now i seen somewhere that there is a level shifter type of thingy, is that right ?.
At this time i am using a unmodified wire.h (i have not got a si570 yet, in post )

I have added 4 more bands (6m,4m,2m(a) and 2m(b).
the 2m(a) displays as 14.4000, but should be 144.0000
the 2m(b) displays as 14.5000, but should be 145.0000
what needs to be done to make it display as i want ?

I think that there might be a few more things that are not right.

Howard

SI570 CODE.rar (3.78 KB)

Can you attach the code uncompressed, or compressed with something standard like ZIP or GZ format? Not everyone has the software to decode RAR.

ok will do zip

Howard

ok heres the zip file of the code

NewZip_si570.zip (3.92 KB)

void setup(){
  lcd.begin(20, 4);

  
  //the "wire" library is modified to disable the internal pull-up resistors
  //so that the external 3.3v pull up required with si570 works
  Wire.begin();

  // Force Si570 to reset to initial freq
  i2c_write(si570_i2c_address,135,0x01);
  read_si570();

  //set the initial frequency
  setFrequency(14150000L);

Is it just me or is this setting the freq to 14,150,000Hz? Maybe needs one more zero...

Hi
i just put another zero in and it made a mess of the freqs

Howard

Well 'long' should be able to hold a value like 141,000,000 (up to 2,147,483,647) (http://arduino.cc/en/Reference/Long), but somewhere else in the code you may be overflowing. Changing all long variable declarations to unsigned long and all 'L' constants to be 'UL' may help.

Or, you may be inadvertently getting cast to int somewhere. For example, your display code may be casting your frequency into an int so you may want to add these:

if (refreshDisplay != 0){
if (menuMode == 0){
if (ritOn == HIGH)
sprintf(b, "%8ld", u[/u]frequency + (long)ritOffset);
else
sprintf(b, "%08ld", u[/u]frequency);
sprintf(c, " %.2s.%.4s%c ", b, b+2, ritOn ? 'R' : ' ');
printLine2(c);
refreshDisplay = 0;

have changed to this, did not do anything

if (refreshDisplay != 0){
if (menuMode == 0){
if (ritOn == HIGH)
sprintf(b, "%8ld", (long)frequency + (long)ritOffset);
else
sprintf(b, "%08ld", (long)frequency);
sprintf(c, " %.2s.%.4s%c ", b, b+2, ritOn ? 'R' : ' ');
printLine2(c);
refreshDisplay = 0;

Changing all long variable declarations to unsigned long and all 'L' constants to be 'UL' may help.

not sure about this

Howard

"%08ld"

It is formatted for 8 places, you need 9 for 141.000.000 I think.
73!

So when you say it made a mess of the freqs, what does that mean? What is exactly is being displayed on the LCD?

You might try a serial.print of your frequency to see if the problem is in the variable or in the display.