Herzlich Willkommen, lieber Gast!
  Sie befinden sich hier:

  Forum » VC++ / MFC » Ladesteuerungs für Redlab 1008 von Meilhaus Elektronic

Forum | Hilfe | Team | Links | Impressum | > Suche < | Mitglieder | Registrieren | Einloggen
  Quicklinks: MSDN-Online || STL || clib Reference Grundlagen || Literatur || E-Books || Zubehör || > F.A.Q. < || Downloads   

Autor Thread - Seiten: > 1 <
000
05.03.2010, 17:07 Uhr
TJunker



Hallo,

habe für ein Abschlussprojekt "Messdatenerfassung mit dem PC" mir von Meilhaus Elektronic das Redlab ME 1008 gekauft.

das RedLAB 1008 ist hat die Möglichkeit über mehrere Eingänge Spannungen einzulesen sowie über D/A Ausgänge zu schalten bzw auszugeben.

Nun möchte ich anhand der mitgelieferten Programmbibliothek und Anwendungsbeispielen mir eine Art Ladesteurung programmieren bzw. zusammenstellen.


Das Programm soll dauerhaft während des Ladens einer Batterie die Spannung messen und sobald die gemessene Spannung geringer ist als die zuvor eingelesene Spannug, über den D/A Ausgang ein Relai geschaltet werden.


Mein Problem besteht nun darin das ich zwar geringe Kenntnisse in Borland habe aber in Visual Studio noch nie was gemacht habe.


hat jemand von euch evt. schonmal was ähnliches für ein ME-Redlab 1008 o. xxxx programmiert? oder kann mir einen Tip geben wie ich unter Visual Studio Express mir anhand der Beispiele den Code für dieses eigentlich recht einfache Programm zusammenstellen kann.

Vielen Dank schonmal im Voraus
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
001
05.03.2010, 17:09 Uhr
TJunker



/*************************************************************************
*
* WINCAI01 - Measurement Computing Universal Library Demo Program
*
* (c) Copyright 1995-2002, Measurement Computing
* All rights reserved.
*
* File: WINCAI01.C
*
* This is an example Windows program that uses the Universal Library to
* display data on channel 0. Double click the top left corner to halt
* the program.
*
* Requirements:
* Board #0 (as installed with InstaCal) must have an A/D converter.
*
* The A/D board must support a -5 to +5 volt range. If the voltage range for
* the A/D is set via switches on the board then the board should be set for
* that range. If the range for your board is software selectable then the
* program will automatically set that range.
*
* To use a different voltgae range, change the ADRANGE definitions below.
*
* Functions: WinMain
* MainMessageHandler
*
**********************************************************************/

/* Include files */

#include <windows.h> /* Compiler's include files's */
#include <string.h>
#include <stdio.h>
#include "..\cbw.h" /* Universal Library's include file */

#define BOARD_NUM 0 /* Number of A/D board as defined with InstaCal */
#define ADRANGE BIP5VOLTS /* A/D voltage range */
#define TIMER_NUM 1 /* Windows timer used by this program */

HWND hWndMain; /* handle for main window */

LONG FAR PASCAL MainMessageHandler (HWND, UINT, WPARAM, LPARAM);

/************************************************************************
*
* Name: WinMain
*
* Arguments: hInstance - the instance handle for the program
* hPrevInstance - the class name of the application (not used)
* CmndLine - command line was called with (not used)
* CmndShow - indicates how to display window
*
* This is the entry point to the program. It gets called by Windows
* to start the program up. This routine creates the main window,
* initializes a timer, and then falls into the main Windows Get
* message/Dispatch message loop.
*
************************************************************************/

int PASCAL
WinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR CmdLine, int nCmdShow)
{
MSG msg; /* MSG structure to pass to windows proc */
WNDCLASS wndclass;
char *AppName; /* Name for the window */

cbErrHandling (PRINTALL, STOPALL); /* Set library's error handling */

CmdLine = NULL; /* Not used */
AppName = "WINCDEMO"; /* The name of this application */
if(!hPrevInstance)
{
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc= MainMessageHandler;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon (hInstance, AppName);
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
wndclass.hbrBackground = GetStockObject (WHITE_BRUSH);
wndclass.lpszMenuName = AppName;
wndclass.lpszClassName = AppName;
RegisterClass (&wndclass);
}

/* create application's Main window */
hWndMain = CreateWindow (AppName, /* Window class name */
"AIn Demo",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, /* Use default X, Y */
CW_USEDEFAULT, /* Use default X, Y */
GetSystemMetrics(SM_CXSIZE) * 12, /* x - fit text */
GetSystemMetrics(SM_CYSIZE) * 10, /* y - fit text */
NULL, /* Parent window's handle */
NULL, /* Default to Class Menu */
hInstance, /* Instance of window */
NULL); /* Create struct for WM_CREATE */


if (hWndMain == NULL)
{
MessageBox(NULL, "Could not create window in WinMain", NULL, MB_ICONEXCLAMATION);
return (1);
}

ShowWindow(hWndMain, nCmdShow); /* Display main window */
UpdateWindow(hWndMain);

// /* Start a 500ms timer to update display */
if(!SetTimer(hWndMain, TIMER_NUM, 50, NULL))
{
MessageBox(NULL, "Error starting Windows timer", NULL, MB_OK |
MB_ICONEXCLAMATION);
return (1);
}

while(GetMessage(&msg, NULL, 0, 0)) /* Main message loop */
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

UnregisterClass (AppName, hInstance);
return (msg.wParam);
}



/************************************************************************
*
* Name: MainMessageHandler
*
* Arguments: hWnd - handle to the window
* Message - message that needs to be handled
* hParam - message parameter
* lParam - message parameter
*
* This is the message dispatcher that gets called whenever Windows
* sends a message to this window. WinMain started up a timer that
* sends a message every 1/2 sec. When the message (WM_TIMER)is received
* by this routine, it reads the A/D.
* It also causes a screen update which will automatically generate a
* WM_PAINT message. The WM_PAINT handler takes care of converting the
* raw A/D values to voltages and printing them in the Window.
*
************************************************************************/

LONG FAR PASCAL
MainMessageHandler(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
HDC hDC; /* handle for the display device */
PAINTSTRUCT ps; /* holds PAINT information */
TEXTMETRIC tm; /* holds TEXT information */

static HRGN hRgn; /* Rectangle region Handles */
static int CharWidth, CharHeight;
static unsigned short DataVal;
int x, y;
char OutString[80], *str;
float Voltage;

switch (Message) /* Windows Message Loop */
{
case WM_CREATE:
hDC = GetDC(hWndMain); /* Get the device context for window */
GetTextMetrics(hDC, &tm); /* From context, get size of font */
CharWidth = tm.tmAveCharWidth;
CharHeight = tm.tmHeight + tm.tmExternalLeading;
ReleaseDC(hWndMain, hDC);
hRgn = CreateRectRgn(0,0, CharWidth*30, CharHeight*12);
break;

case WM_TIMER: /* All Timer Events Processed Here */
InvalidateRgn(hWndMain, hRgn, FALSE); /* Force screen update */
break;

case WM_PAINT: /* Repaint client area of window */
hDC = BeginPaint(hWndMain, &ps);
x = CharWidth * 2; /* Position cursor within window */
y = CharHeight; /* One line down and 2 chars in */
str = " A/D Info"; /* Print title */
TextOut(hDC, x, y, str, strlen (str));

y += CharHeight; /* Print current index */
cbAIn (BOARD_NUM, 0, ADRANGE, &DataVal);

y += CharHeight*2; /* Print raw data value */
sprintf (OutString,"Raw A/D value = %u ", DataVal);
TextOut(hDC, x, y, OutString, strlen (OutString));

y += CharHeight; /* Convert raw A/D to volts and print */
cbToEngUnits (BOARD_NUM,ADRANGE,DataVal,&Voltage);
sprintf (OutString,"Voltage = %.2f ", Voltage);
TextOut(hDC, x, y, OutString, strlen (OutString));

SetTextAlign(hDC, TA_LEFT | TA_TOP);
EndPaint(hWndMain, &ps);
break;

case WM_CLOSE: /* Close the window */
DestroyWindow(hWnd);
if (hWnd == hWndMain)
PostQuitMessage(0); /* Send message to Quit application */
break;

default:
return (DefWindowProc(hWnd, Message, wParam, lParam));
}
return (0l);
}
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
002
05.03.2010, 17:47 Uhr
TJunker



BEISPIELE AUS DER HEADERDATEI


// Get log file name

// store the preferences
int EXTCCONV cbLogSetPreferences(int timeFormat, int timeZone, int units);

// get the preferences
int EXTCCONV cbLogGetPreferences(int* timeFormat, int* timeZone, int* units);

// Get log file name
int EXTCCONV cbLogGetFileName(int fileNumber, char* path, char* filename);

// Get info for log file
int EXTCCONV cbLogGetFileInfo(char* filename, int* version, int* fileSize);

// Get sample info for log file
int EXTCCONV cbLogGetSampleInfo(char* filename, int* sampleInterval, int* sampleCount,
int* startDate, int* startTime);

// Get the AI channel count for log file
int EXTCCONV cbLogGetAIChannelCount(char* filename, int* aiCount);

// Get AI info for log file
int EXTCCONV cbLogGetAIInfo(char* filename, int* channelNumbers, int* units);

// Get CJC info for log file
int EXTCCONV cbLogGetCJCInfo(char* filename, int* cjcCount);

// Get DIO info for log file
int EXTCCONV cbLogGetDIOInfo(char* filename, int* dioCount);

// read the time tags to an array
int EXTCCONV cbLogReadTimeTags(char* filename, int startSample, int count, int* dateTags, int*timeTags);

// read the analog data to an array
int EXTCCONV cbLogReadAIChannels(char* filename, int startSample, int count, float* analog);

// read the CJC data to an array
int EXTCCONV cbLogReadCJCChannels(char* filename, int startSample, int count, float* cjc);

// read the DIO data to an array
int EXTCCONV cbLogReadDIOChannels(char* filename, int startSample, int count, int* dio);

// convert the log file to a .TXT or .CSV file
int EXTCCONV cbLogConvertFile(char* srcFilename, char* destFilename, int startSample, int count, int delimiter);

int EXTCCONV cbDaqInScan(int BoardNum, short *ChanArray, short *ChanTypeArray, short *GainArray, int ChanCount, long *Rate,
long *PretrigCount, long *TotalCount, HGLOBAL MemHandle, int Options);
int EXTCCONV cbDaqSetTrigger(int BoardNum, int TrigSource, int TrigSense, int TrigChan, int ChanType,
int Gain, float Level, float Variance, int TrigEvent);
int EXTCCONV cbDaqSetSetpoints (int BoardNum, float *LimitAArray, float *LimitBArray, float *Reserved, int *SetpointFlagsArray,
int *SetpointOutputArray, float *Output1Array, float *Output2Array, float *OutputMask1Array,
float *OutputMask2Array, int SetpointCount);

int EXTCCONV cbDaqOutScan(int BoardNum, short *ChanArray, short *ChanTypeArray, short *GainArray, int ChanCount, long *Rate,
long Count, HGLOBAL MemHandle, int Options);
int EXTCCONV cbGetTCValues(int BoardNum, short *ChanArray, short *ChanTypeArray, int ChanCount, HGLOBAL MemHandle, int FirstPoint,
long Count, int Scale, float *TempValArray);

int EXTCCONV cbVIn (int BoardNum, int Chan, int Gain, float *DataValue, int Options);
int EXTCCONV cbVIn32 (int BoardNum, int Chan, int Gain, double *DataValue, int Options);
int EXTCCONV cbVOut (int BoardNum, int Chan, int Gain, float DataValue, int Options);

int EXTCCONV cbDeviceLogin(int BoardNum, char* AccountName, char* Password);
int EXTCCONV cbDeviceLogout(int BoardNum);

int EXTCCONV cbTEDSRead(int BoardNum, int Chan, BYTE* DataBuffer, long *Count, int Options);
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
Seiten: > 1 <     [ VC++ / MFC ]  


ThWBoard 2.73 FloSoft-Edition
© by Paul Baecher & Felix Gonschorek (www.thwboard.de)

Anpassungen des Forums
© by Flo-Soft (www.flo-soft.de)

Sie sind Besucher: