SDI Shield with Arduino uno wifi rev2

Ask software engineering and SDK questions for developers working on Mac OS X, Windows or Linux.
  • Author
  • Message
Offline

PI3RRE

  • Posts: 2
  • Joined: Fri Sep 27, 2019 9:26 am
  • Real Name: Pierre Rey

SDI Shield with Arduino uno wifi rev2

PostFri Sep 27, 2019 9:36 am

Hi,

I'm currently integrating an SDI BlackMagic Shileds on an Arduino uno wifi rev2

I'have issue to detect the SDI Shields. I tried default sketch provided and it's not working.
Each time I start the sketch there are an infinite loop on sdiTallyControl.begin() (regRead32())

I tried those connection with the Shiels :
1) SDA, SCL pinout of the wifi rev2
2) A4, A5 pinout of the wifi rev2
3) 0(RX), 1(TX) Serial port of the wifi rev2 (Adapting code to use BMD_SDITallyControl_Serial
4) SDA, SCL pinout of the wifi rev2 remap physically to the pin A4, A5 of the SDI Shields

The Shield is power by an 12V 1A alimentation.
During the boot the Shileds LEDs 2,3,4,5,6 light up very quickly and than only the LED 1 stay on.

The SDI Shileds is correctly detected on the compture via USB and it's configured in 1080i50 at 0x65 default adress

I tried to run I2C scanner with in the 1, 2, 3 connectivity scenario. The only detected address is 0x60 (even if I remove the SDI shield) which I suppose to be the Wifi module.

Does anyone have idea why the SDI Shiled does not reply over I2C or Serial ?

Regards
Offline

PI3RRE

  • Posts: 2
  • Joined: Fri Sep 27, 2019 9:26 am
  • Real Name: Pierre Rey

Re: SDI Shield with Arduino uno wifi rev2

PostSat Nov 02, 2019 11:57 am

Hi,

I finnaly found a workaround by using Serial port on the Uno Wifi Rev2.
We need to adjust the library file BMDSerialPhysical.h to make it working with Hardware Serial port "Serial1"
diffchecker.com/LKpuNLZi


After updated file BMDSerialPhysical.h you can use it in project :
Code: Select all
BMD_SDITallyControl_Serial sdiTallyControl(Serial1);
BMD_SDICameraControl_Serial sdiCameraControl(Serial1);


Exemple :
Code: Select all
/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
*/

#include "Arduino.h"
#include <BMDSDIControl.h>                                // need to include the library

BMD_SDITallyControl_Serial sdiTallyControl(Serial1);

// the setup function runs once when you press reset or power the board
void setup()
{
  pinMode(LED_BUILTIN, OUTPUT);                                     // initialize digital pin 13 as an output
  digitalWrite(LED_BUILTIN, HIGH);
 
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  delay(1000);
  Serial.println("tally begin");
  sdiTallyControl.begin();                                 // initialize tally control
  Serial.println("tally setOverride");
  sdiTallyControl.setOverride(true);                       // enable tally override 

}

// the loop function runs over and over again forever
void loop()
{
  digitalWrite(LED_BUILTIN, HIGH);                                  // turn the LED ON
  Serial.println("setCameraTally 1 programm on");
  sdiTallyControl.setCameraTally(                          // turn tally ON
    1,                                                     // Camera Number
    true,                                                  // Program Tally
    false                                                  // Preview Tally
  );

  delay(1000);                                             // leave it ON for 1 second

  digitalWrite(LED_BUILTIN, LOW);                                   // turn the LED OFF
  Serial.println("setCameraTally 1 programm off");
  sdiTallyControl.setCameraTally(                          // turn tally OFF
    1,                                                      // Camera Number
    false,                                                 // Program Tally
    false                                                  // Preview Tally
  );

  delay(1000);                                             // leave it OFF for 1 second
}


BMDSerialPhysical.h :
Code: Select all
/* -LICENSE-START-
 ** Copyright (c) 2016 Blackmagic Design
 **
 ** Permission is hereby granted, free of charge, to any person or organization
 ** obtaining a copy of the software and accompanying documentation covered by
 ** this license (the "Software") to use, reproduce, display, distribute,
 ** execute, and transmit the Software, and to prepare derivative works of the
 ** Software, and to permit third-parties to whom the Software is furnished to
 ** do so, all subject to the following:
 **
 ** The copyright notices in the Software and this entire statement, including
 ** the above license grant, this restriction and the following disclaimer,
 ** must be included in all copies of the Software, in whole or in part, and
 ** all derivative works of the Software, unless such copies or derivative
 ** works are solely in the form of machine-executable object code generated by
 ** a source language processor.
 **
 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 ** FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
 ** SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
 ** FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
 ** ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 ** DEALINGS IN THE SOFTWARE.
 ** -LICENSE-END-
 */

#pragma once

#include <stdint.h>
#include <Arduino.h>

namespace BMD
{
   template <typename T>
   class SerialPhysical : public T
   {
   public:
      SerialPhysical(void) {}
      SerialPhysical(HardwareSerial &serialClass) : //Type UartClass for other UNO
         m_serial(&serialClass)
      {}
      
      // Inherits from T
      virtual void      begin();
      virtual uint32_t   regRead32(uint16_t address) const;
      virtual void      regWrite32(uint16_t address, uint32_t value) const;
      virtual uint16_t   regRead16(uint16_t address) const;
      virtual void      regWrite16(uint16_t address, uint16_t value) const;
      virtual uint8_t      regRead8(uint16_t address) const;
      virtual void      regWrite8(uint16_t address, uint8_t value) const;
      virtual void      regRead(uint16_t address, uint8_t values[], int length) const;
      virtual void      regWrite(uint16_t address, const uint8_t values[], int length) const;

   private:
      enum
      {
         kSync1Value = 0xDC,
         kSync2Value = 0x42,
      };
      HardwareSerial *m_serial = &Serial; //Type UartClass for other UNO
   };

   template <typename T>
   void SerialPhysical<T>::begin()
   {
      m_serial->begin(38400);

      T::begin();
   }

   template <typename T>
   uint32_t SerialPhysical<T>::regRead32(uint16_t address) const
   {
      uint8_t regBytes[4];

      uint8_t request[] = {
         kSync1Value,
         kSync2Value,
         (uint8_t)(address & 0xFF),
         (uint8_t)(address >> 8),
         'R',
         4,
         0
      };
      m_serial->write(request, sizeof(request));

      m_serial->flush();

      while (m_serial->available() < 4);
      regBytes[0] = m_serial->read();
      regBytes[1] = m_serial->read();
      regBytes[2] = m_serial->read();
      regBytes[3] = m_serial->read();

      return ((uint32_t)regBytes[3] << 24) | ((uint32_t)regBytes[2] << 16) | ((uint32_t)regBytes[1] << 8) | regBytes[0];
   }

   template <typename T>
   void SerialPhysical<T>::regWrite32(uint16_t address, uint32_t value) const
   {
      uint8_t request[] = {
         kSync1Value,
         kSync2Value,
         (uint8_t)(address & 0xFF),
         (uint8_t)(address >> 8),
         'W',
         4,
         0
      };
      m_serial->write(request, sizeof(request));
      m_serial->write(value >> 0);
      m_serial->write(value >> 8);
      m_serial->write(value >> 16);
      m_serial->write(value >> 24);

      m_serial->flush();
   }

   template <typename T>
   uint16_t SerialPhysical<T>::regRead16(uint16_t address) const
   {
      uint8_t regBytes[2];

      uint8_t request[] = {
         kSync1Value,
         kSync2Value,
         (uint8_t)(address & 0xFF),
         (uint8_t)(address >> 8),
         'R',
         2,
         0
      };
      m_serial->write(request, sizeof(request));

      m_serial->flush();

      while (m_serial->available() < 2);
      regBytes[0] = m_serial->read();
      regBytes[1] = m_serial->read();

      return ((uint16_t)regBytes[1] << 8) | regBytes[0];
   }

   template <typename T>
   void SerialPhysical<T>::regWrite16(uint16_t address, uint16_t value) const
   {
      uint8_t request[] = {
         kSync1Value,
         kSync2Value,
         (uint8_t)(address & 0xFF),
         (uint8_t)(address >> 8),
         'W',
         2,
         0
      };
      m_serial->write(request, sizeof(request));
      m_serial->write(value >> 0);
      m_serial->write(value >> 8);

      m_serial->flush();
   }

   template <typename T>
   uint8_t   SerialPhysical<T>::regRead8(uint16_t address) const
   {
      uint8_t request[] = {
         kSync1Value,
         kSync2Value,
         (uint8_t)(address & 0xFF),
         (uint8_t)(address >> 8),
         'R',
         1,
         0
      };
      m_serial->write(request, sizeof(request));

      m_serial->flush();

      while (m_serial->available() < 1);
      return m_serial->read();
   }

   template <typename T>
   void SerialPhysical<T>::regWrite8(uint16_t address, uint8_t value) const
   {
      uint8_t request[] = {
         kSync1Value,
         kSync2Value,
         (uint8_t)(address & 0xFF),
         (uint8_t)(address >> 8),
         'W',
         1,
         0
      };
      m_serial->write(request, sizeof(request));
      m_serial->write(value);

      m_serial->flush();
   }

   template <typename T>
   void SerialPhysical<T>::regRead(uint16_t address, uint8_t values[], int length) const
   {
      uint8_t request[] = {
         kSync1Value,
         kSync2Value,
         (uint8_t)(address & 0xFF),
         (uint8_t)(address >> 8),
         'R',
         (uint8_t)length,
         0
      };
      m_serial->write(request, sizeof(request));

      m_serial->flush();

      for (int i = 0; i < length; i++)
      {
         while (m_serial->available() < 1);
         values[i] = m_serial->read();
      }
   }

   template <typename T>
   void SerialPhysical<T>::regWrite(uint16_t address, const uint8_t values[], int length) const
   {
      uint8_t request[] = {
         kSync1Value,
         kSync2Value,
         (uint8_t)(address & 0xFF),
         (uint8_t)(address >> 8),
         'W',
         (uint8_t)length,
         0
      };
      m_serial->write(request, sizeof(request));
      m_serial->write(values, length);

      m_serial->flush();
   }
}
Offline
User avatar

Leoseona

  • Posts: 3
  • Joined: Sat Nov 09, 2019 10:34 am
  • Real Name: Madlen Gevti

Re: SDI Shield with Arduino uno wifi rev2

PostMon Nov 11, 2019 7:12 pm

The only detected address is 0x60 (even if I remove the SDI shield) which I suppose to be the Wifi module.
Offline
User avatar

Leoseona

  • Posts: 3
  • Joined: Sat Nov 09, 2019 10:34 am
  • Real Name: Madlen Gevti

Re: SDI Shield with Arduino uno wifi rev2

PostMon Nov 11, 2019 7:12 pm

The only detected address is 0x60 (even if I remove the SDI shield) which I suppose to be the Wifi module.

Return to Software Developers

Who is online

Users browsing this forum: No registered users and 45 guests