Hi members,
I signed up in this forum because I have a problem which drives me crazy since days.
I have a working sketch on a Arduino UNO R3 board with an simple external 500kHz Receiver.
The external circuit is powered by a PWM Output Pin of the Arduino. The Output of the receiver will be fed back to the arduino into the analouge A0 pin. Depending on the Signalstrength coming back into the Arduino the receiver Power on the PWM Output is regulated - this is a kind of initial start procedure. As soon as the Output value of the receiver reaches a certain level, the voltage coming from the PWM Output will then be fixed.
Then the Receiver is calibrated and the normal program starts running in the arduino. It listens on the A0 port and if a spike occures a counter increases. So far the function which is working perfect on the Arduino board.
I produced a PCB for the Receiver and the ATMega328P-PU circuit togehter to free the arduino board.
The ATMega328P-PU circuit is equiped with a 5V stabilized Power Supply (LM7805, with 100µF and 100nF on the input side and on the output side). The ATMega328P-PU runs with an external 16MHz clock with 2x22pF and a 16MHz quartz). The VCC and the AVCC Pin is connected to 5V, The AREF pin is connected to ground via 100nF.
Everything is controlled many many times. The PCB is correct but the calibration procedure does not work. The circuit starts but the PWM output stays at 0 and the switches to the normal running mode.
It is the same code and the same circuit used with the Arduino board and the external receiver.
In the meantime I am "death by google".... I don´t have any idea why my code does not work on the external board. I tried 3 ATMega328P-PU "hoping" that one of them is damaged. Everytime the same result.
Some things I have in mind - which I can not verify because of an google overflow with no detailed informations.
-) Is there any special procedure to upload a special bootloader when I use an external 16MHz quartz?
-) Is there any special bootloader for an external breadboard?
-) Is there any special code to use for the ADC when using on an external breadboard?
I will attach some codesnipps of my code.
I am really disapointed in the moment because I do not have a plan how my project can continue.
Perhaps some of you is wanting to support me - that would be very helpful. Especially with detailed descriptions. I am quite new to the Arduino technology.
Thank you very much and best regards
FTF
Here are some code parts. If someone is interrested in the whole code then please send me a message. I will provide the code then.
defining the Pins
const int U_Empfaenger_PIN=9;
const int IN_Signal_PIN=A0;
Defining the I2C 20x4 LCD display
//I2C LCD Display Settings
#define I2C_ADDR 0x3F
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
Prescaler definition of the ADC
// Define various ADC prescaler
const unsigned char PS_32 = (1 << ADPS2) | (1 << ADPS0);
in the "void setup()"
pinMode(IN_Signal_PIN, INPUT);
pinMode(U_Empfaenger_PIN, OUTPUT);
// set up the ADC
ADCSRA &= ~PS_128; // remove bits set by Arduino library
ADCSRA |= PS_32; // set our own prescaler to 32
The calibration code is
void Kalibrieren()
{
unsigned long Startzeit=0;
unsigned long Endzeit=0;
int Intervall=1000;
int Signal= analogRead(IN_Signal_PIN);
int U_Empfaenger=0;
int AmpMax=0;
int AmpWork=0;
int Trigger=0;
int i=0;
do
{
unsigned long Startzeit=millis();
if (Startzeit - Endzeit > Intervall)
{
lcd.setCursor(0, 0);
lcd.print("#Messungen ");
lcd.setCursor(12, 0);
lcd.print(i);
lcd.setCursor(0, 1);
lcd.print("Receiver ");
lcd.setCursor(12, 1);
lcd.print(U_Empfaenger);
lcd.setCursor(0, 3);
lcd.print("Version 1_2_2");
Endzeit = Startzeit;
U_Empfaenger=U_Empfaenger+1;
analogWrite(U_Empfaenger_PIN, U_Empfaenger);
i=0;
}
else
{
i=i+1;
Signal = analogRead(IN_Signal_PIN);
if (Signal > 500)
{
Trigger=Trigger+1;
AmpMax=U_Empfaenger;
}
}
}while (Trigger < 1);
AmpWork=AmpMax;
U_Empfaenger=(int)(AmpWork*0.5);
analogWrite(U_Empfaenger_PIN, U_Empfaenger);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("U_Empfang ");
lcd.setCursor(0, 1);
lcd.print(U_Empfaenger);
delay(1000);
}