CP0100 Testeur d'assemblage de diodes automatique à base
d'Arduino
CP0100 vous permet de tester les diodes, ponts redresseur et autres
assemblages de diodes de mainière totalement automatique.
Il suffit de brancher et de lire le résultat....
Vidéo de présentation du hardware
Vidéo de présentation du software
Voici le schéma du biniou
Un internante, David Arcos a dévelopé un petit soft PC qui lit le port série et affiche le résultat. Cela permet de faire le testeur avec juste un arduino nano et 3 résistances ! Vous pouvez le télécharger ici Appli PC de David Il faut spécifier le port dans le fichier .ini Vous pouvez le contacter ici: ahyone (aroba) hotmail.com . Un grand merci à lui pour sa sympathique contribution.
=====================================================================================
========================== OPEN SOURCE
LICENCE ==================================
=====================================================================================
Copyright 2019 Philippe Demerliac Cyrob.org
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"),
to deal in the Software without restriction, including without
limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
................................................................................................................
Release history
................................................................................................................
Version Date
Author Comment
1.0d1 17/02/19
Phildem First blood Class DPack validated
1.0 20/02/19
Phildem Final Ok
1.1 22/02/19
Phildem Misc source corection and Display startur
count down
*/
//Version
#define kInitMsg "*** CP0100 v1.1 Cyrob
***" // Init msg send to serial Port
#define
kOutLed1Red
6 // Led 1 (Pin 0 state) Red
#define kOutLed1Green
7 // Led 1 (Pin 0 state) Green
#define
kOutLed2Red
8 // Led 2 (Pin 1 state) Red
#define kOutLed2Green
9 // Led 2 (Pin 1 state) Green
#define
kOutLed3Red 10 // Led
3 (Pin 2 state) Red
#define kOutLed3Green
A4 // Led 3 (Pin 2 state) Green
#define
kOutLed4Red A5 // Led
4 (Pin 3 state) Red
#define kOutLed4Green
11 // Led 4 (Pin 3 state) Green
#define kDispTicksPeriod_ms
100 // value of display ticker in ms
#define
kSerialPeriod_tick 10
// Result sent on serial port delay in ticks
#define kLedBlinkDelay_tick
10 // Led blinker Ticker in ticks
//Real Pin mapping
byte gTestPins[4]= {kIoPin0, kIoPin1, kIoPin2, kIoPin3}; //
Test pin affectation
byte gLedPins[kNbLed+kLedGreenOf7]= {kOutLed1Red, kOutLed2Red,
kOutLed3Red, kOutLed4Red,kOutLed1Green, kOutLed2Green, kOutLed3Green,
kOutLed4Green}; // led red first, green second
//============================================================================================================
// Class DPack, package analyseur
//____________________________________________________________________________________________________________
class DPack {
public:
//============================================================
// Must be called once to define signatures of Dpack instance
void Init(const char* Sign1,const char* Sign2,const char*
Sign3,const char* Sign4){
strcpy(m_TSign[0],Sign1);
strcpy(m_TSign[1],Sign2);
strcpy(m_TSign[2],Sign3);
strcpy(m_TSign[3],Sign4);
};
//==========================================================================================
//Test current device fill up Resu with char[1..4] the pin
Led Code char [0] is rsrv for type
bool Test(char* Resu){
strcpy(Resu,"E....");
m_Used=0;
for (int p=0;p<4;p++){
char
r=_GetPinStatus(p);
if
(r==kLedCodeUnknown)
return false;
else
Resu[p+1]=r;
}
return (true);
}
private:
//====================================================================================
// Look for the associated sign for the Pin, return
kLedCodeUnknown if not found
char _GetPinStatus(const int Pin){
// Count nbr of positiv pins in NbP
char NbP='0';
_OutPlus(Pin);
for (int p=0;p<4;p++){
if
(digitalRead(gTestPins[p])==HIGH)
NbP++;
}
// Count nbr of negativ pins in NbM
char NbM='0';
_OutMinus(Pin);
for (int p=0;p<4;p++){
if
(digitalRead(gTestPins[p])==LOW)
NbM++;
}
// Look For Sign
for (int s=0;s<4;s++){
if
(!bitRead(m_Used,s) && m_TSign[s][0]==NbP
&& m_TSign[s][1]==NbM){
bitSet(m_Used,s);
return m_TSign[s][2];
}
}
return kLedCodeUnknown;
}
//====================================================================================
// Set the given pin to positive voltage and the other as
input with external pulldown
void _OutPlus(const int Pin){
for(int p=0;p<4;p++){
if (p==Pin){
pinMode(gTestPins[p],OUTPUT);
digitalWrite(gTestPins[p], HIGH);
}
else {
pinMode(gTestPins[p],INPUT);
}
}
delay(kDpackIoSetDelay_ms);
}
//===================================================================================
// Set the given pin to positive voltage and the other as
input with Internal pullup
void _OutMinus(const int Pin){
for(int p=0;p<4;p++){
if (p==Pin){
pinMode(gTestPins[p],OUTPUT);
digitalWrite(gTestPins[p], LOW);
}
else {
pinMode(gTestPins[p],INPUT_PULLUP);
}
}
delay(kDpackIoSetDelay_ms);
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Members
char m_TSign[4][4]; //Signature storage
byte
m_Used;
// Bitfield to not reuse pins and imrove error detection
};
//Global Var
...............................................................................................
char
gResu[6];
// Last measurement
DPack
gTPack[kNbpack];
// Analyser object instances array
unsigned long
gLastMilli
=
0;
// Last milli for tickers
byte
gSerTickCount =
0;
// Serial Ticker counter
byte
gLedTicker
=
0;
// Led blinker Ticker counter
//============================================================================================================
// Test Engine
//____________________________________________________________________________________________________________
//============================================================
// Scan all type for current device and fill Resu with result
// Resu[0] is type '0' to '6' 'E' if err, Resu[1..4] is led Status
status, Resu[5] is Null (terminator)
void TestDevice(char* Resu){
for (int t=0;t<kNbpack;t++)
if
(gTPack[t].Test(Resu)){
Resu[0]='0'+t;
Resu[5]=0; // Zero T
return;
}
strcpy(Resu,"EUUUU");
}
//============================================================================================================
// UI Led Control
//____________________________________________________________________________________________________________
//===================================================================================
// Init Led must be called once at init
void InitLed(){
for (int L=0;L<kNbLed + kLedGreenOf7;L++)
pinMode(gLedPins[L],OUTPUT);
}
//===================================================================================
// Do The Start up sequence
void LedStartup(byte Step){
for (int L=0;L<kNbLed + kLedGreenOf7;L++)
digitalWrite(gLedPins[L],L==Step);
}
//===================================================================================
// Display Pins status on the Led, must be called every tick
void LedIdle(){
if (gLedTicker-- == 0)
gLedTicker=kLedBlinkDelay_tick;
for (int L=0;L<kNbLed;L++){
switch (gResu[L+1]) {
case
kLedCodeAnode:
// Red
digitalWrite(gLedPins[L], HIGH);
digitalWrite(gLedPins[L+kLedGreenOf7], LOW);
break;
case
kLedCodeCathode: // Green
digitalWrite(gLedPins[L], LOW);
digitalWrite(gLedPins[L+kLedGreenOf7], HIGH);
break;
case
kLedCodeJunction:
digitalWrite(gLedPins[L], gLedTicker>=kLedBlinkDelay_tick/2);
digitalWrite(gLedPins[L+kLedGreenOf7],
gLedTicker<kLedBlinkDelay_tick/2);
break;
case
kLedCodeOff:
// Off
digitalWrite(gLedPins[L], LOW);
digitalWrite(gLedPins[L+kLedGreenOf7], LOW);
break;
//============================================================================================================
// UI Display Control
//____________________________________________________________________________________________________________
//===================================================================================
// Init Display must be called once at init
void InitDisplay(){
pinMode(kOutDispA,OUTPUT);
pinMode(kOutDispB,OUTPUT);
pinMode(kOutDispC,OUTPUT);
pinMode(kOutDispD,OUTPUT);
}
//===================================================================================
// Do The Start up sequence
void DisplayStartup(byte Step){
gResu[0]='9'-Step;
DisplayIdle();
}
//===================================================================================
// Display result type on display, must be called every tick
void DisplayIdle(){
char V;
if (gResu[0]=='E')
V=14; // To Display 'E'
else
V=gResu[0]-'0';
//============================================================================================================
// Serial Port Control
//____________________________________________________________________________________________________________
//===================================================================================
// Init Serial must be called once at init
void InitSerial(){
Serial.begin(kSerBaudRate);
}
//===================================================================================
// Do The Start up sequence
void SerialStartup(byte Step){
if (Step==1)
Serial.println(kInitMsg);
}
//===================================================================================
// Send result, must be called every tick
void SerialIdle(){
if (gSerTickCount-- == 0)
{
Serial.println(gResu);
gSerTickCount=kSerialPeriod_tick;
}
// StartUp
for (int S=0;S<=10;S++){
SerialStartup(S);
LedStartup(S);
DisplayStartup(S);
delay(200);
}
}
//============================================================================================================
//Arduino Main Loop
//____________________________________________________________________________________________________________
void loop() {
// Analyse Connexion pins
TestDevice(gResu);
// I/O Ticker
unsigned long CurMilli=millis();
if (gLastMilli>CurMilli) // Timer RollOver
protection
gLastMilli=0;
if (CurMilli -
gLastMilli>=kDispTicksPeriod_ms){
// On Tick
gLastMilli=CurMilli;
// Call all UI and IO idle
SerialIdle();
LedIdle();
DisplayIdle();
} // of Ticker loop
}
Ce
site utilise des frames. Si vous ne voyez pas
les menus à gauche, cliquez
Ici