Hello everyone. There is a problem that i found and i dont know what cause it , me or conrtoller.
I'm using TM4C123 board and energia for fast coding and checking .
MY code :
#include <stdint.h>
#include <math.h> // round(x)
#include <Wire.h>
#include <SPI.h>
#include <SparkFunMLX90614.h>
#include <FastDigitalWrite.h>
#include <TFTv2.h>
#include <Servo.h>
#define MAX_ROWS 120
#define MAX_COUMNS 160
#define V_SERVO_MAX_ANGLE 120
#define H_SERVO_MAX_ANGLE 160
IRTherm therm ;
Servo H_Servo ;
Servo V_Servo ;
float arrayRaw [MAX_ROWS][MAX_COUMNS] ;
uint16_t arrayInteger [MAX_ROWS][MAX_COUMNS] ;
uint16_t arraySorted [MAX_ROWS * MAX_COUMNS] ;
int i ,j ,l ,m ,k ,count = 0 ;
void setup() {
H_Servo.attach(PD_0) ;
V_Servo.attach(PD_1) ;
/*
Tft.begin(PC_4,PC_6,PC_7,PC_5) ; // CS ,DC ,BL ,RESET pin
Tft.TFTinit() ; // Init TFT library
Tft.backlight_on() ;
*/
therm.begin() ;
therm.setUnit(TEMP_C) ;
pinMode(PF_1,OUTPUT) ; // User Led for indicating
pinMode(PA_5,OUTPUT) ; // Laser pointer
}
void Border () {
digitalWrite(PA_5,HIGH) ;
V_Servo.write(0);
H_Servo.write(0);
delay(1000) ;
for( m = 0 ; m < 3 ; m++) {
for( k = 0 ; k <= 3 ; k++) {
delay(100) ;
if (count == 0) {
for( l = 0 ; l < 90 ; l++) {
V_Servo.write(l);
delay(15);
}
count++ ;
}
else if (count == 1) {
for( l = 0 ; l < 90 ; l++) {
H_Servo.write(l);
delay(15);
}
count++ ;
}
else if (count == 2) {
for( l = 90 ; l > 0 ; l--) {
V_Servo.write(l);
delay(15);
}
count++ ;
}
else if (count == 3) {
for( l = 90 ; l > 0 ; l--) {
H_Servo.write(l);
delay(15);
}
count++ ;
}
else {
count = 0 ;
}
}
}
digitalWrite(PA_5,LOW) ;
count = 0 ;
}
void Scaner () {
for(j = 0; j < 90; j += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
digitalWrite(PF_1,HIGH) ;
H_Servo.write(j); // tell servo to go to position in variable 'pos'
delay(50); // waits 15ms for the servo to reach the position
if((j+1)%2 == 0){
for(i = 90; i > 0; i-=1) // goes from 180 degrees to 0 degrees
{
V_Servo.write(i); // tell servo to go to position in variable 'pos'
delay(50); // waits 15ms for the servo to reach the position
digitalWrite(PF_1,LOW) ;
}
}
else {
for(i = 0; i < 90; i += 1) // goes from 0 degrees to 180 degrees
{
V_Servo.write(i); // tell servo to go to position in variable 'pos'
delay(50); // waits 15ms for the servo to reach the position
digitalWrite(PF_1,LOW) ;
}
}
}
}
void loop() {
Border() ;
Scaner() ;
//therm.object() ;
}
Here just 2 functions are executing , both of them are using PWM attached to PD0 and PD1. My problem is that sometime there is present a twitch and i can see it also on my scope without conected servos (i can see how pulse width is chenging radomly and after some time it "stabilizes" and follows the code).
Sometimes one of the chenels just stops working. And this happens with a totaly new board , that has 3-5 days .
I've tried on board power pins and my breadboard power source. I checked this source without load (servos) and with servos conected to it . My scope shows me that this twitch is not caused by this source. And i want to ask you guys , did anyone had problem like this , or do anyone know what is the cause?
P.S I've desoldered R9 and R10 before i started using it.
And one more thing to mention : this problem is not only on PD0 and PD1 , i saw it on PB6,7 ; PE4,5 also. I have not checked other chenels.
