Show Posts
Pages: [1] 2 3 ... 173
1  Community / Exhibition / Gallery / Re: 3D Ultrasonic Radar. on: Today at 10:23:42 am
Updates, part 2.


Enjoy.
2  Using Arduino / Programming Questions / Re: Averaging multiple inputs only when connected using one standard sketch on: August 17, 2014, 11:59:09 pm
Quote
Unfortunately the end user won't be able to alter the sketch, so the pins have to remain analog from the start
He doesn't have to altered a sketch.  You setting pinMode command inside setup(), than reading status and use it in "if" statement.
Here is quasy code:
Code:
 
int an0 = 0;  // If "0" - disconnected, default state.
int an1 = 0;
int an2 = 0
void setup()
{
 Serial.begin(115200) ;
  pinMode(14, OUTPUT); // Analog 0
 digitalWrite(14, HIGH);
 delay(100);
   an0 =  digitalRead(14);
  pinMode(15, OUTPUT); // Analog 0
 digitalWrite(15, HIGH);
 delay(100);
   an1 =  digitalRead(15);
  pinMode(16, OUTPUT); // Analog 0
 digitalWrite(16, HIGH);
 delay(100);
   an2 =  digitalRead(16);
}

 loop()
{
if ( an0 ) --->> use data to average;
if ( an1 ) --->> use data to average;
if ( an2 ) --->> use data to average;
3  Products / Arduino Due / Re: Due Counter Overflow Interrupt Problem on: August 15, 2014, 08:52:14 am
The code in reply #2 I use in my latest project, where I need to cascade two timers,  chaining output TC0-0 to TC0-1, that gives me two freq. primary and another lower by /N, both synchronous. I'm setting SYNC in interrupt handler .

 Library, as I can see doesn't have an API to select external source.  SAM3X data sheet 'd explain all other details in the snippet,
4  Using Arduino / Programming Questions / Re: Averaging multiple inputs only when connected using one standard sketch on: August 14, 2014, 10:05:29 pm
I'd set analog pin as digital first, set pull-up and read status. If not connected, most likely you get 1. To make it work reliably, analog voltage has to be lower 2V and less tha 10k impedance.
5  Products / Arduino Due / Re: Due Counter Overflow Interrupt Problem on: August 14, 2014, 07:03:34 pm
It's not clear what external freq. is. You mixing up a library code with your own, and I'm afraid it's not gonna to work. Library seems to me doesn't have external events counting, so it's always running from internal clock, and what worse its setting different clock (preselector) based of the freq. you are setting up.
 If the objective of your project to count external pulses with highest possible resolution , max freq. 42 MHz - limited by input pin synchronization circuits, than timer overrun in 4294967296/42000000 = 102 sec. 
Anyway here a code snippets , that you will have to adjust in some way:
Code:
void tmB_setup ()
{
  uint32_t reg_val;
  pmc_enable_periph_clk (TC_INTERFACE_ID + 0 *3 + 1) ;  // clock the TC0 channel 1

  reg_val = TC_BMR_TC1XC1S_TIOA0;   <<<---- TC_BMR_TC1XC1S_TCLK1;  in your case, replace, and use Analog pin 5
  TC0->TC_BMR = reg_val;  <<<<--- selects External clock

    TcChannel * t = &(TC0->TC_CHANNEL)[1];
    t->TC_CCR = TC_CCR_CLKDIS; 
    t->TC_IDR = 0xFFFFFFFF;     
    t->TC_SR;                   
    t->TC_CMR = TC_CMR_TCCLKS_XC1 | //  Because TC0 Channel-1
          TC_CMR_WAVE |                  // waveform mode
          TC_CMR_WAVSEL_UP_RC |          // I'd leave it's as it is, and set 1000 000 or another "good" number instead of FFFFF
          TC_CMR_EEVT_XC1 |     //
          TC_CMR_ACPA_CLEAR | TC_CMR_ACPC_CLEAR |
          TC_CMR_BCPB_CLEAR | TC_CMR_BCPC_CLEAR ;
         
  t->TC_RC = frm_rate * 227;    // < here, 1000 000   
  t->TC_RA = 3;                 // whatever
  t->TC_CMR = (t->TC_CMR & 0xFFF0FFFF) | TC_CMR_ACPA_CLEAR | TC_CMR_ACPC_SET ;  // probably you don't need this
  t->TC_CCR = TC_CCR_CLKEN | TC_CCR_SWTRG ;  // re-enable local clocking and switch to hardware trigger source. 
  t->TC_IER =  TC_IER_CPCS;
  t->TC_IDR = ~TC_IER_CPCS;
//  NVIC_EnableIRQ(TC1_IRQn); // enable TC0 interrupts
}

void TC1_Handler(){
  uint32_t reg_val0 = REG_TC0_SR1; // vital - reading this clears some flag
                                   // otherwise you get infinite interrupts

// your code
}

6  Using Arduino / General Electronics / Re: Ultrasonic sensor circuit design on: August 14, 2014, 04:02:24 pm
Don't expect big changes in SNR,  compare to R10 (1M) R5 and R6 produced 100x times less noise.  Other things if you still want to make your own circuits, not coping anything else design,  I'd suggest to decrease a gain of 1-st stage, right now its close to 5000. If OPA is not oscillating, than its over limits of the OPA  anyway , at 40 kHz it's probably 100-250 at max,  don't have data sheet at hands, do your home work check it up
7  Using Arduino / General Electronics / Re: Ultrasonic sensor circuit design on: August 14, 2014, 09:10:18 am
You don't need R5/R6.  Have you tried to google "HC-SR04 schematic" ? Don't invent a wheel, here is correct design:
http://uglyduck.ath.cx/HC-SR04E/HC-SR04.svgz
8  Using Arduino / Sensors / Re: Reading an oxygen sensor on: August 14, 2014, 12:07:29 am
I'd vote for diagram 40, w/o rcv420, direct drive AinP with AinN grounded.
9  Using Arduino / General Electronics / Re: Arduino Due: Minimum reading of "20" on analog inputs on some PCBs on: August 12, 2014, 06:38:33 pm
Here a quote from STM32F103 data sheet:
Quote
Calibration
The ADC has an built-in self calibration mode. Calibration significantly reduces accuracy
errors due to internal capacitor bank variations. During calibration, an error-correction code
(digital word) is calculated for each capacitor, and during all subsequent conversions, the
error contribution of each capacitor is removed using this code.
Analog-to-digital converter (ADC)
Calibration is started by setting the CAL bit in the ADC_CR2 register. Once calibration is
over, the CAL bit is reset by hardware and normal conversion can be performed. It is
recommended to calibrate the ADC once at power-on. The calibration codes are stored in
the ADC_DR as soon as the calibration phase ends.
Note:
1 It is recommended to perform a calibration after each power-up.
2 Before starting a calibration the ADC must have been in power-off state (ADON bit = ‘0’) for
at least two ADC clock cycles.
Looks like Atmel has not implemented this nice feature in its uCPU. So, external circuitry, if its just 3 resistors would be necessary, and than some code to measure at start-up time and subtract this offset later on. Things may get complicated when gain and differential mode in use. 
10  Using Arduino / General Electronics / Re: Arduino Due: Minimum reading of "20" on analog inputs on some PCBs on: August 12, 2014, 11:47:53 am
Quote
The solution is to use either software or hardware calibration.
Yes, that what I thought, but I couldn't find any reference in the data sheet how to invoke a recalibration of the ADC.  Anyone knows?
For example, on Maple (STM32 cortex-3 , practically same uCPU as ARM SAM3X), you can run:
Code:
adc_enable(ADC1);
    adc_calibrate(ADC1);
11  Community / Exhibition / Gallery / 3D Ultrasonic Radar. on: August 10, 2014, 10:52:23 am


 And short description: http://coolarduino.wordpress.com/2014/08/10/virtual-touch-screen-3d-ultrasonic-radar/

Have a nice day.
12  Using Arduino / Programming Questions / Re: Measure Frequency/Mph of Piezo Vibration Sensor(Analog) on: August 05, 2014, 06:23:10 am
In response to edited reply #5:
Quote
The only problem is, if I'll be using 3 vibration sensor I'll need an external analog comparator, yes? Could you recommend one for me?
No, you need 3 arduinos. Comparator internally configured to ICP. What is the ICP , look in the data sheet of AtMega328.
I'm not advising on the part number and sourcing.  Post another topic.
With alll due respect, have you considered to build a project with LEGO, instead of arduino?
13  Using Arduino / Audio / Re: Correcting Waveform Centre on: August 04, 2014, 08:51:23 am
Scale your DDS around 128,  with positive +127 and negative -127. Than put a cap to eliminate DC offset, about 2.5V
14  Using Arduino / Project Guidance / Re: Measuring distance with RF on: August 04, 2014, 08:46:19 am
Quote
I just read about micros() having a 4microsecond resolution, that equates to 1.2km
Just don't use pulseIn, get timing from ICP - input capture of Timer1 running 16 MHZ, 62.5 nsec.
If you take DUE with 84MHz uCPU clock, you will get about 5 m resolution.
Averaging over 256 ping's would increase this value down to ~1 m or so.
May be slow for real time flying plane
15  Using Arduino / Programming Questions / Re: Measure Frequency/Mph of Piezo Vibration Sensor(Analog) on: August 04, 2014, 05:44:27 am
Quote
Sir, is it okay if I use a digital pin for my sensor?
Yes, if you build a circuitry to bias comparator inputs.
Quote
The code in the link you gave me only displays "FreqPeriod Library Test" even when I bend my sensor.
Bend? Do not, you can easily destroy sensor or your arduino.  Tip a pencil on a desk, where the sensor placed
Pages: [1] 2 3 ... 173