Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Why so many errors from the simulation?

Status
Not open for further replies.

laoadam

Member level 2
Joined
Feb 22, 2019
Messages
52
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
324
Hi,
I am testing a circuit from:
and came out so many errors.
pp17.PNG


pp18.PNG


Code:
#define analogPin 0        
#define chargePin 13        
#define dischargePin 11      
#define resistorValue 10000.0F  

unsigned long startTime;
unsigned long elapsedTime;
float microFarads;              
float nanoFarads;

void setup(){
  pinMode(chargePin, OUTPUT);    
  digitalWrite(chargePin, LOW);
  Serial.begin(9600);

  Serial.print("test");
}

void loop(){
  digitalWrite(chargePin, HIGH);
  startTime = millis();
  while(analogRead(analogPin) < 648){      
  }

  elapsedTime= millis() - startTime;
  microFarads = ((float)elapsedTime / resistorValue) * 1000;  
  Serial.print(elapsedTime);      
  Serial.print(" mS    ");        

  if (microFarads > 1){
    Serial.print((long)microFarads);      
    Serial.println(" microFarads");        
  }

  else{
    nanoFarads = microFarads * 1000.0;    
    Serial.print((long)nanoFarads);        
    Serial.println(" nanoFarads");        
    delay(500);
  }

  digitalWrite(chargePin, LOW);          
  pinMode(dischargePin, OUTPUT);          
  digitalWrite(dischargePin, LOW);        
  while(analogRead(analogPin) > 0){        
  }

  pinMode(dischargePin, INPUT);          
}
 

As a guess, the board pin definitions are missing. Either there is a missing header file, library file or you have the wrong board selected.

Brian.
Thanks.
Maybe the Nano's pin definitions? where can get one please?
This sheet is a child sheet from a main design, is this a matter?
 

It is probably specific to the design. You need to include the other 'sheets' for it to work at at the very least copy the relevant parts of them into your block of code.

Brian.
 
It is probably specific to the design. You need to include the other 'sheets' for it to work at at the very least copy the relevant parts of them into your block of code.

Brian.
Thank you,
You are right, it is cause of the child sheet.
I made a new circuit and the NANO simulation well.
So how to simulate the child ?
 

Can you help about this Sub_circuit's simulation please?
Code:
const int pwmPin = 12; // assigns pin 12 to variable pwm

const int potcyc = A0; // assigns analog pot input A0 to vary the cyc of pwm
const int potfre = A1; // assigns analog pot input A1 to vary the cfrequency of pwm


void setup()  // setup loop
{
  pinMode(pwmPin, OUTPUT);
  // Don't use pinMode() with analogRead()
}

void loop()
{
  float dutyCycleVal = analogRead(potcyc) / 1024.0;
  int delayVal = map(analogRead(potfre), 0, 1024, 2000, 0); // delay in

  digitalWrite(pwmPin, HIGH);
  delayMicroseconds(delayVal * dutyCycleVal); // The ON part of the cycle
  digitalWrite(pwmPin, LOW);
  delayMicroseconds(delayVal * (1.0 - dutyCycleVal));  // The OFF part of the cycle
}

main.1.png


sub.1.png
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top