element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Experts, Learning and Guidance
  • Technologies
  • More
Experts, Learning and Guidance
Ask an Expert Forum Querry about scp1000 on arduino
  • Blog
  • Forum
  • Documents
  • Leaderboard
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Experts, Learning and Guidance to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 5 replies
  • Subscribers 278 subscribers
  • Views 11695 views
  • Users 0 members are here
Related
See a helpful answer?

Be sure to click 'more' and select 'suggest as answer'!

If you're the thread creator, be sure to click 'more' then 'Verify as Answer'!

Querry about scp1000 on arduino

Former Member
Former Member over 12 years ago

Hi there

 

I am working on Arduino and having problem regarding interfacing SCP1000 with arduino uno along with i2c protocol as i hv no knowledge of this.
can any boby help me in this regard???

 

regards

Asad

  • Sign in to reply
  • Cancel
  • fidelsalinas
    0 fidelsalinas over 12 years ago

    howdy,

     

    Here is the arduino code for the SCP1000:

    // define spi bus pins
    #define SLAVESELECT 10
    #define SPICLOCK 13
    #define DATAOUT 11      //MOSI
    #define DATAIN 12       //MISO
    #define UBLB(a,b)  ( ( (a) << 8) | (b) ) 
    #define UBLB19(a,b) ( ( (a) << 16 ) | (b) )
    
    
    //Addresses
    #define REVID 0x00      //ASIC Revision Number
    #define OPSTATUS 0x04   //Operation Status
    #define STATUS 0x07     //ASIC Status
    #define START 0x0A      //Constant Readings
    #define PRESSURE 0x1F   //Pressure 3 MSB
    #define PRESSURE_LSB 0x20 //Pressure 16 LSB
    #define TEMP 0x21       //16 bit temp
    
    
    char rev_in_byte;           
    int temp_in;
    unsigned long pressure_lsb;
    unsigned long pressure_msb;
    unsigned long temp_pressure;
    unsigned long pressure;
    
    
    void setup()
    {
      byte clr;
      pinMode(DATAOUT, OUTPUT);
      pinMode(DATAIN, INPUT);
      pinMode(SPICLOCK,OUTPUT);
      pinMode(SLAVESELECT,OUTPUT);
      digitalWrite(SLAVESELECT,HIGH); //disable device  
      
      SPCR = B01010011; //MPIE=0, SPE=1 (on), DORD=0 (MSB first), MSTR=1 (master), CPOL=0 (clock idle when low), CPHA=0 (samples MOSI on rising edge), SPR1=0 & SPR0=0 (500kHz)
      clr=SPSR;
      clr=SPDR;
      delay(10);
      Serial.begin(9600);                        
      delay(500);
    
    
      Serial.println("Initialize High Speed Constant Reading Mode"); 
      write_register(0x03,0x09);
    }
    
    
    void loop()
    {
      
      rev_in_byte = read_register(REVID);
      
      pressure_msb = read_register(PRESSURE);
      pressure_msb &= B00000111;
      pressure_lsb = read_register16(PRESSURE_LSB);
      pressure = UBLB19(pressure_msb, pressure_lsb);
      pressure /= 4;
      
      Serial.print("PRESSURE [");
      Serial.print(pressure, DEC);
      Serial.println("]");
      
      temp_in = read_register16(TEMP);
      temp_in = temp_in / 20;
      temp_in = ((1.8) *temp_in) + 32;
      Serial.print("TEMP F [");
      Serial.print(temp_in , DEC);
      Serial.println("]");
     
      delay(1500);
      
    }
    
    
    char spi_transfer(volatile char data)
    {
      SPDR = data;                    // Start the transmission
      while (!(SPSR & (1<<SPIF)))     // Wait for the end of the transmission
      {
      };
      return SPDR;                    // return the received byte
    } 
    
    
    
    
    char read_register(char register_name)
    {
        char in_byte;
        register_name <<= 2;
        register_name &= B11111100; //Read command
       
        digitalWrite(SLAVESELECT,LOW); //Select SPI Device
        spi_transfer(register_name); //Write byte to device
        in_byte = spi_transfer(0x00); //Send nothing, but we should get back the register value
        digitalWrite(SLAVESELECT,HIGH);
        delay(10);
        return(in_byte);
       
    }
    
    
    float read_register16(char register_name)
    {
        byte in_byte1;
        byte in_byte2;
        float in_word;
        
        register_name <<= 2;
        register_name &= B11111100; //Read command
    
    
        digitalWrite(SLAVESELECT,LOW); //Select SPI Device
        spi_transfer(register_name); //Write byte to device
        in_byte1 = spi_transfer(0x00);    
        in_byte2 = spi_transfer(0x00);
        digitalWrite(SLAVESELECT,HIGH);
        in_word = UBLB(in_byte1,in_byte2);
        return(in_word);
    }
    
    
    void write_register(char register_name, char register_value)
    {
        register_name <<= 2;
        register_name |= B00000010; //Write command
    
    
        digitalWrite(SLAVESELECT,LOW); //Select SPI device
        spi_transfer(register_name); //Send register location
        spi_transfer(register_value); //Send value to record into register
        digitalWrite(SLAVESELECT,HIGH);
    }

     

    hope this helps,

    Fidel Salinas

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 12 years ago in reply to fidelsalinas

    This code is implemented in spi protocol but the model i am using is

    scp1000 d11 which works on i2c protocol.if u can help me in that,i will be

    thankful to you

     

    regards

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • fidelsalinas
    0 fidelsalinas over 12 years ago in reply to Former Member

    Here is the code for the SCP1000 D11 using the i2c:

     

    Deprecated code

     

    Good Luck,

    Fidel Salinas

    AFS Technologies

    AFS labs

     

    Message was edited by: Fidel Salinas

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 12 years ago in reply to fidelsalinas

    After executing this code i got masage that this code having no void loop, no void setup and main exist so i tried a lot but it doesnot correct kindly add them and if someone have code of it kindly give me .... i am stuck in it ...

     

    i shall be very thankful to you.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • fidelsalinas
    0 fidelsalinas over 12 years ago in reply to Former Member

    sorry that last code didn't work out for you, but I did find a library that didn't work with 1.0 and up, did a little bit of editing, everything compiled and now we should have a working i2c library for 1.0v. Here is a link SCP1000-D11 ,

     

    Regards,

    Fidel Salinas

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube