Announcement

Collapse
No announcement yet.

Any arduino wire code?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Any arduino wire code?

    i am trying to use wire.h on the arduino to Wire.send(..) messages to the SOMO connected via analog pins 4/5 (SCL/SDA), but am unable to make the SOMO respond. would be much obliged if someone can just help post an example sketch
    thanks in advance

  • #2


    Hi,
    Please find attached the 4DGL code for serial communication between SOMO-14D and a Goldelox display module. You can extract some of the code snippets out of it and translate them to your language of programming. Two digital I/Os are used in this code. Serial commands are sent by bit-banging the digital I/Os.

    -Bilal

    Attached files SOMO_4DGL.4dg (5.3 KB)

    Comment


    • #3


      Any code for the SOMO and Ardunio? I an unable to get them to communicate.

      Thanks in advance!

      Comment


      • #4


        Hi,
        There are simple Play/Stop or Next/Previous and Volume control inputs in KEY mode which you can simply control through the Digital outputs of your host controller. Please see the SOMO-14D datasheet for this configuration (KEY Mode).

        There is another configuration called Serial Mode where you can use only two digital outputs of your host controller to control the SOMO module. Remember "Serial Mode" here does not mean the Serial Com port with Serial protocol. It is simple bit banging at a specific rate to feed the data in to SOMO at every clock bit. See the Timing diagram in the Datasheet.
        -Bilal

        Comment


        • #5


          Ok, here is what I have for Ardunio and the SOMO-14D.
          It works!
          I modified 4dSystems' code to work. Arduino's ShiftOut command does not comply with the required 200us clock width (< 2 us).

          Enjoy!
          Doyle



          /*************************************************
          * Filename: SOMODuino
          * Created: 22 April 2010
          * Author: Doyle Maleche -> maleche1 at comcast dot net
          * Description: Arduino code to test the SOMO-14D with Serial
          * Modifed code from 4dsystems to work with Arduino
          * Version: 0.1
          **************************************************/
          //
          // Use HyperTerminal or any Terminal program to benefit from the screen refresh
          // This code is works with the Arduino
          // Please let me know of any updates you may add so I can learn from it.

          const unsigned int minVol= 0xfff0; // Minimum volume
          const unsigned int maxVol= 0xfff7; // Max Volume
          const unsigned int PlyPse = 0xfffe; // Play or Pause
          const unsigned int Stop= 0xFFFF; // Stop
          const int pinClock= 3;
          const int pinData =4;
          const int pinBusy =6;
          const int pinReset=7;
          unsigned int volLevel=0x0005;
          int Song; // current Song
          unsigned int vol; // current volume


          void setup(){
          Serial.begin(9600);
          pinMode(pinData,OUTPUT); // set pin 4 to output for Data
          pinMode(pinClock,OUTPUT); // set pin 3 to output for data
          pinMode(pinReset,OUTPUT); // set pin 7 to allow software reset
          pinMode(pinBusy,INPUT); // set pin 6 to monitor while Song is playing
          Reset();
          }

          void loop()
          {
          int cmd;
          if (Serial.available()>0) {
          cmd=Serial.read(); // Read the user command
          delay(10);
          Serial.println(cmd,BYTE); // Print user selection
          // Check user input command. You could use the CASE/SWITCH function here instead of IF
          if (cmd==110){nextPlay();} //"n" =Play Next Song
          if (cmd==112){pausePlay();} //"p" =Pause/Play
          if (cmd==116){stopPlay();} //"t" = Stop Play
          if (cmd==115){PlaySong();} //"sx"; x=Play Song Number
          if (cmd==105){incVol();} //"i" = Increase Volume
          if (cmd==100){decVol();} //"d" = Decrease Volume
          if (cmd==114){Reset();} //"r" = Reset
          if (cmd==99){CycleSongs();} //"c" = Cycle through all Songs

          delay(2000); // Pause 2 seconds to show User selection
          Menu(); //Refresh Menu
          }

          }

          void Menu()
          {
          Serial.print(12,BYTE); // Clear terminal. Works with real terminal programs like HyperTerminal. Ardunio's serial monitor will not clear.
          Serial.println("*************************************");
          Serial.println("* SOMO-14D *");
          Serial.println("* Arduino Serial controlled *");
          Serial.println("* Test and Evaluation *");
          Serial.println("*************************************");
          Serial.println();
          Serial.println("n = Play Next Song");
          Serial.println("p = Pause or Play current Song");
          Serial.println("t = Stop current Song");
          Serial.println("sxxx = Play Song number 000 - 511");
          Serial.println("i = Increase Volume");
          Serial.println("d = Decrease Volume");
          Serial.println("c = Cycle through all Songs");
          Serial.println("r = Reset SOMO and goto sleep");
          Serial.println("=====================================");
          Serial.print("Enter command > ");
          }


          /**********************************************************************************
          Send Sequence
          **********************************************************************************/

          void sendData(int ThisSong)
          {
          int TheSong = ThisSong;
          int ClockCounter=0;
          int ClockCycle=15;//0x0f;
          digitalWrite(pinClock,HIGH); // Hold (idle) for 300msec to prepare data start
          delay(300);
          digitalWrite(pinClock,LOW); //Hold for 2msec to signal data start
          delay(2); //2msec delay

          while(ClockCounter = 512 || SongNumber = 0 && SongNumber < 512){ // Song is within range limit
          Serial.print("-> Song No.");
          Serial.println(SongNumber);
          sendData(SongNumber);}

          }

          /**********************************************************************************
          Plays the next Song in the Sequence
          **********************************************************************************/
          void nextPlay()
          {
          if (Song >= 0 && Song < 512){ Song++;} // should be within the 512 number range
          if (Song >= 512 || Song = minVol && vol < maxVol){ vol++;} // should be within the volume range
          if (vol >= maxVol | vol minVol && vol = maxVol | vol

          Comment


          • #6


            Hello to everybody,
            Thanks so much for your code, Maleche. Anyway, it doesn't work in my somo-14D module:
            I have a problem with the module, it doesn't work fine, I developed my own code and captured some screens with the logic analyzer. As you can see the timing and signals are right (0x0002 command sent) but it plays the wrong track (0000 and 0001 plays track1, 0002 and 0003 plays track2...) or plays a track in a wrong way (track 1 says "Miguel", but it plays something similar to "MiguelMi" or "Javier" it plays "Jav" only...). I tried with 4 uSD cards, all 2GB capacity, some cards works like this I described, some directly doesn't work. Also I formated (quick and complete format) the cards before writting the files.
            Also I tried Maleche's Somoduino code, but the result is exactly the same, so I guess it's not a software problem...
            Could anybody help me, please?
            Thanks in advance and greetings!Miguel. Attached files

            Comment


            • #7


              Problem solved,
              I created an empty file called 01FF.AD4 and copied it to the uSD card. The first I do is playing that file (nothing sounds for few time, busy light on) and after everything works fine. I don't know why this works, but it does...
              Greetings.

              Comment

              Working...
              X