Notifications
Clear all

[Solved] LGT8F328P LQFP32 MiniEVB, “Pro Mini” code error? (Arduino IDE)

5 Posts
2 Users
1 Likes
84 Views
 j526
(@j526)
Member
Joined: 4 weeks ago
Posts: 17
Topic starter  

Does anyone here use the MiniEVB Arduino compatibles?

My "Pro Mini" LQFP32 behaves strange. The blynk executes properly but if i upload something more serious then the board resets itself  every iteration, on random moments or even goes completely stuck. For comparison, i uploaded the same code to the MEGA 2560 and it executes perfectly. Both tests were executed without additional external hardware, so that is not that.

I do not know if there is some library incompatibility or i have a damaged chip...

Code i have used:

#include <Servo.h>

//define input frequency/ period
int input_frequency = 16000; //[Hz]
//period = 1000000/input_frequency; //[us] , 62.5
int period = 63; //[62,5 us] 

//define input pins
int M1 = 10;
int M2 = 11; 
int M3 = 12;
int M4 = 13;
//define read containers
int pwm1, pwm2, pwm3, pwm4;
//define output pins
int S1 = 2;
int S2 = 3; 
int S3 = 5;
int S4 = 6;
//create servo objects
Servo Out1, Out2, Out3, Out4;


void setup() {
  Serial.begin(115200);

  pinMode(M1, INPUT);
  pinMode(M2, INPUT);
  pinMode(M3, INPUT);
  pinMode(M4, INPUT);
  
  Out1.attach(S1);  // attaches the servo on a pin to the servo object
  Out2.attach(S2); 
  Out3.attach(S3); 
  Out4.attach(S4); 
}

void loop() {
  read_pwms();

  print_to_serial(pwm1, pwm2, pwm3, pwm4);

  write_to_servos(pwm1, pwm2, pwm3, pwm4);

  Serial.println(random(0, 1000)); 
}

void print_to_serial(int v1, int v2, int v3, int v4){
  Serial.print(v1);
  Serial.print("\t");
  Serial.print(v2);
  Serial.print("\t");
  Serial.print(v3);
  Serial.print("\t");
  Serial.print(v4);
  Serial.println("");
}

void read_pwms(){
  pwm1 = read_pwm(M1, period);
  pwm2 = read_pwm(M2, period);
  pwm3 = read_pwm(M3, period);
  pwm4 = read_pwm(M4, period);
}

int read_pwm(int pin, int timeout_us){
  int pulse_value_us = 0;
  int pwm_percent = 0;
  int pulse_value_ns;
  int timeout_ns = timeout_us * 1000;  
  if(digitalRead(pin) == HIGH){ //inactive state of the motor
    pulse_value_us = pulseIn(pin, LOW, timeout_us);
    pulse_value_ns = pulse_value_us * 1000;
    pwm_percent = map(pulse_value_ns, 0, timeout_ns, 0, 100);
  }else{
    pulse_value_us = pulseIn(pin, HIGH, timeout_us);
    if(pulse_value_us == 0){
      pwm_percent = 100;
    }else{
      pulse_value_ns = pulse_value_us * 1000;
      pwm_percent = map(pulse_value_ns, 0, timeout_ns, 0, 100);      
    }
  }
  return(pwm_percent);
}

void write_to_servos(int val1, int val2, int val3, int val4){
  Out1.write(val1);
  Out2.write(val2);
  Out3.write(val3);
  Out4.write(val4);
  // delay(15);
}

More about the MiniEVB boards:

https://wolles-elektronikkiste.de/en/minievb-boards-an-overview

https://wolles-elektronikkiste.de/en/lgt8f328p-lqfp32-boards

 

 


   
Quote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7007
 

Posted by: @j526

Does anyone here use the MiniEVB Arduino compatibles?

My "Pro Mini" LQFP32 behaves strange. The blynk executes properly but if i upload something more serious then the board resets itself  every iteration, on random moments or even goes completely stuck. For comparison, i uploaded the same code to the MEGA 2560 and it executes perfectly. Both tests were executed without additional external hardware, so that is not that.

I do not know if there is some library incompatibility or i have a damaged chip...

Code i have used: DELETED

More about the MiniEVB boards:

https://wolles-elektronikkiste.de/en/minievb-boards-an-overview

https://wolles-elektronikkiste.de/en/lgt8f328p-lqfp32-boards

 

It may be you need to change the clock and processor. Get a magnifying glass and see what you can see, or just try all 4 until one works. See attached pic to understand what I am talking about. I have some of those clone ProMini boards and it took me a while to figure it out.

Screenshot 2024 04 13 at 12.50.14

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
 j526
(@j526)
Member
Joined: 4 weeks ago
Posts: 17
Topic starter  

@zander 

Thank you for the hint. However, it does not work for me.

Much more interesting, how did you have performed this screen shot? For me the menu disappears when i try to shoot it.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7007
 

@j526 I am on a Mac, maybe that explains it, but you can get Windows/Mac/*nix add on screen grabbers that can do that.

I have never heard of those boards you are using, but unless they have some special feature you need, why mess with an unknown, just switch to a NANO or whatever Arduino Board suits your needs. 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
 j526
(@j526)
Member
Joined: 4 weeks ago
Posts: 17
Topic starter  

Why... because i can. And because i have them.
A little bit more seriously, it's an interesting board for a very good price, why to not use it then. The same way someone could ask why to develop new boards if they exists a Uno. Or why to respond a post without the experience the author was asking for. I am not asking that. You can, i do not want to prohibit that.

I have checked my code with an Nano compatible EVB board (which has the same uC) and it works ok, so it is left to assume that my previous board was not ok. It's the first time i have a not working new uC so i am a little bit surprised, but of course everything could happen from time to time.


   
Ron reacted
ReplyQuote