Pages: 1 2 [3]   Go Down
Author Topic: "parlare con ogni parte dell'Arduino"  (Read 2289 times)
0 Members and 1 Guest are viewing this topic.
Campagne Aretine
Offline Offline
God Member
*****
Karma: 0
Posts: 816
Arduino è una figata
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

come fai a dire al chip "cambia la frequenza"? con la freq di pwm? comunque complimenti, hai visto che alla fine ce l'hai fatta smiley-razz
se devi cambiare la frequenza del pwm devi mettere mano al prescaler e potrebbero iniziare un po' di beghe :S
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 27
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

scusa l'ignoranza... cos'è il pwm?
prescaler??? oddio!
Logged

Campagne Aretine
Offline Offline
God Member
*****
Karma: 0
Posts: 816
Arduino è una figata
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

scusa non avevo ben capito come funzionava sto coso, tu lo piloti tramite i2c o busmode?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 27
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I2C
Logged

Castelletto Sopra Ticino, IT
Offline Offline
Full Member
***
Karma: 0
Posts: 169
Yes we can!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

http://www.google.it/search?q=PWM
Logged

Campagne Aretine
Offline Offline
God Member
*****
Karma: 0
Posts: 816
Arduino è una figata
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

posta il codice che hai scritto per pilotare quell'oggettino.
Ho visto nel codice di esempio che per settare una stazione devi fare questa roba :
Code:
//Tunes the AR1000 to a given station.
//Calculate AR1000 CHAN id  :  Freq (MHz) = 69 + 0.1*CHAN
//Example, sending 973 will tune to 97.3MHz
void ar1000_tuneto(uint16_t freq_kHz)
{
      uint16_t channel, temp;

      /*
      1) Set hmute Bit
      2) Clear TUNE Bit
      3) Clear SEEK Bit
      4) Set BAND/SPACE/CHAN Bits
      5) Enable TUNE Bit
      6) Wait STC flag (Seek/Tune Comlete, in Status Register
      7) Clear hmute Bit
      8) Update Functions (optional)
      */

      //Clear tune bit
      AR1000_TUNE_OFF;

      //Set Channel
      channel = freq_kHz - 690;
      temp = ar1000_read(2); //Read
      temp &= 0xFE00; //Mask
      temp |= channel;
      ar1000_write(2, temp); //Write
      
      //Enable tune bit
      AR1000_TUNE_ON;
      
      //Wait for tune to stabilize (STC flag)
      temp = 0;
      while(temp == 0)
      {
            temp = ar1000_read(ADDR_STATUS) & MASK_STC;
            printf("!");
      }
      
}
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 27
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ovviamente l'esempio è stato seguito e quindi quel pezzo di codice c'è!
cmq ti posto il mio codice, che è addirittura più articolare di quello dell'esempio:


Quote
// Wire Master Writer
// by Nicholas Zambetti <http://www.zambetti.com>

// Demonstrates use of the Wire library
// Writes data to an I2C/TWI slave device
// Refer to the "Wire Slave Receiver" example for use with this

// Created 29 March 2006

#include <Wire.h>

#include "radio.h"  
   
// the initial setting of AR1000 register ( base on ARF_V23_080121 )   
   
//#define INTERNAL_XO   // mark this line if you're using external reference clock   
//#ifdef INTERNAL_XO   
uint16_t AR1000reg[18]={ //using  AR1000 XO function  
    0xFFFB,     // R0 -- the first writable register .  
    0x5B15,     // R1.  
    0xD0B9,     // R2.  
    0xA010,     // R3, seekTHD = 16  
    0x0780,     // R4  
    0x28AB,     // R5  
    0x6400,     // R6  
    0x1EE7,     // R7  
    0x7141,     // R8  
    0x007D,     // R9  
    0x82C6,     // R10  disable wrap  
    0x4E55,     // R11. <---    
    0x970C,     // R12.  
    0xB845,     // R13  
    0xFC2D,     // R14  
    0x8097,     // R15  
    0x04A1,     // R16  
    0xDF6A      // R17  
};       
//#else   
//uint16_t AR1000reg[18]={ // using External 32.768KHz Reference Clock   
//    0xFF7B,     // R0 -- the first writable register .  (disable xo_en)   
//    0x5B15,     // R1.   
//    0xD0B9,     // R2.   
//    0xA010,     // R3   seekTHD = 16   
//    0x0780,     // R4   
//    0x28AB,     // R5   
//    0x6400,     // R6   
//    0x1EE7,     // R7   
//    0x7141,     // R8   
//    0x007D,     // R9   
//    0x82C6,     // R10  disable wrap   
//    0x4F55,     // R11. <--- (disable xo_output)   
//    0x970C,     // R12.   
//    0xB845,     // R13   
//    0xFC2D,     // R14   
//    0x8097,     // R15   
//    0x04A1,     // R16   
//    0xDF6A      // R17   
//};       
//#endif   
   
// Volume Control   
// there are two different fields about volume control in AR1000F   
//  Volume   :  D7  ~D10 in register R3   
//  Volume2 :  D12~D15 in register R14   
//  17 combinations of ( volume2 + volume)  are  recommended.   
//     
//     
unsigned char AR1000vol[19]={ // volume control  (increasing) 070822  
     0x0F,    // step 0  
     0xCF,    // step 1  
     0xDF,    // step 2  
     0xFF,    // 3  
     0xCB,    // 4  
     0xDB,    // 5  
     0xFB,    // 6  
     0xFA,    // 7  
     0xF9,    // 8  
     0xF8,    // 9  
     0xF7,    //10  
     0xD6,    //11  
     0xE6,    //12  
     0xF6,    //13  
     0xE3,    //14  
     0xF3,    //15  
     0xF2,    //16    
     0xF1,    //17  
     0xF0 //18 <------ default setting  
};   

DATA_TYPE_S Reg_Data[18];    

byte x = 0;

void loop()
{
//  Wire.beginTransmission(4); // transmit to device #4
//  Wire.send("x is ");        // sends five bytes
//  Wire.send(x);              // sends one byte  
//  Wire.endTransmission();    // stop transmitting

  delay(1000);
  SetAR1000_volume(x);
  x++;
  if (x == 19)
     x = 0;
  //Serial.println(x, DEC);  
}

// ----- AR1000 VerF Sample Code ( v0.85, No-RDS ) by AIROHA Technology Corp. -------   
// Version : 0.85   ( No-RDS)  for using internal XO or external 32.768 KHz reference clock   
// Files : AR1000FSample.c , AR1000FSample.h   
//   
// This sample code presents following functions of AR1000/AR1010:   
//   
//       1. power-on sequence   
//       2.frequency calculation and basic tune    
//  3. tune with Hi/Lo side rejection (** recommended procedure for tune )   
//       4.seek with Hi/Lo side rejection ( and smute)   
//       5.volume control   
//  6. scan(** recommended procedure for scan )    
//  7. standby and wakeup procedure   
//     
// This sample code could be compatiable with RDS function. However,the RDS related    
// opertions are beyond the scope of this sample code and are not presented here.   
// ---------------------------------------------------------------------------------------------------------------   
//   
// Upgrade from 0.84 to 0.85   
// - update register setting   
//   
// Upgrade from 0.82 to 0.83   
// - Conditional compilation ( INTERNAL_XO)   
// - DEMO: standby and wakeup   
// Upgrade from 0.81 to0.82a   
// - register update to ARF_V21_070813  ( disable xo_en & xo output  )   
// - volume control update    
// - make sure hmute is always ON all over the seek and Hi/Lo-tune process   
//   that is ,   AR1000_I2C_TUNE_HiLo (  )  and  AR1000_I2C_TUNE(  )  will MUTE ON   
//   but not MUTE OFF. Caller must MUTE OFF explicitly.   
// - completely scan procedure   
// - errata:     
//                 "if (rssi < 0) ..... "    in AR1000_I2C_TUNE_HiLo (  )      
//         
// Upgrade from 0.80 to 0.81   
// - make sure RDS interrupt is OFF before seek and tune   
// - max output of volume is recommended  (as default setting)   
   
void setup()
{
    Serial.begin(9600);
    
    delay(500);
    
    Wire.begin(); // join i2c bus (address optional for master)
    
    delay(500);
    
//    uint16_t status_;   
//    status_ = AR1000_I2C_Read_Data(ADDR_status_);   
//    //flag = status_ & MASK_STC; // check STC flag 
//    Serial.printl("status: ")
//    Serial.println(status_, HEX);
    
//    int FreqKHz = 690 + ((status_ & MASK_READCHAN )>> SHIFT_READCHAN );
//    Serial.print("freq: ");  
//    Serial.println(FreqKHz, DEC);
  
    uint16_t val;   
    // Get IC version  
    val = AR1000_I2C_Read_Data(ADDR_CHIPID);       
    if( val != CHIPNO_AR1000 ) {  
        // this is not AR1000  
        //return;  
    }
  
    Serial.print("id1: ");
    Serial.println(val, HEX);
       
    val = AR1000_I2C_Read_Data(ADDR_DEVID);
  
    Serial.print("id2: ");
    Serial.println(val, [color=#006
Logged

Pages: 1 2 [3]   Go Up
Jump to: