Hallo,
ich habe mir einen Nanotec PD2-N4118L1804-2 gekauft und das passende
Zubehör von Nanotec (ZK-PD2N - RS485-Anschlusskabel und ZK-RS485-USB -
Konverter) um den Motor mit dem PC zu verbinden.
Ich möchte den Motor mit einem Programm in C# ansprechen, doch leider
klappt das ganze nicht. In der NanoPro Software ist ein Beispiel in C#
geschrieben ist. Das habe ich mir angeschaut und dieses funktioniert
auch. Wenn ich jetzt das Beispiel eins zu eins in ein neues Projekt
übertrage bekomme ich beim ausführen des Programmes folgende
Fehlermeldung:
Es wurde versucht, eine Datei mit einem falschen Format zu laden.
(Ausnahme von HRESULT: 0x80070000B)
Ich habe natürlich die benötigten Verweise zur CommandsPD4I.DLL und auch
zur Command.DLL hinzugefügt und die beiden using Direktiven auch.
Hier noch der Progammcode:
1 | using System;
|
2 | using System.Windows.Forms;
|
3 | using CommandsPD4I;
|
4 | using Command;
|
5 | namespace Motor_Steuerung
|
6 | {
|
7 | public partial class Form1 : Form
|
8 | {
|
9 |
|
10 | public ComMotorCommands motor1;
|
11 |
|
12 | public Form1()
|
13 | {
|
14 | InitializeComponent();
|
15 |
|
16 | motor1 = new ComMotorCommands();
|
17 | }
|
18 |
|
19 | private void button1_Click(object sender, EventArgs e)
|
20 | {
|
21 | motor1.SelectedPort = "COM6";
|
22 | motor1.Baudrate = 115200;
|
23 | motor1.MotorAddresse = 1;
|
24 | motor1.SetPositionType(1);
|
25 | motor1.StartTravelProfile();
|
26 |
|
27 | if (motor1.ErrorFlag)
|
28 | {
|
29 | toolStripStatusLabel1.Text = "Status 1: " + motor1.ErrorMessageString;
|
30 | }
|
31 | else
|
32 | {
|
33 | toolStripStatusLabel1.Text = "Status 1: OK";
|
34 | }
|
35 |
|
36 | }
|
37 | }
|
38 | }
|
Ich hoffe Ihr könnt mir weiterhelfen.