Jump to content

magnaparva

Members
  • Gesamte Inhalte

    14
  • Benutzer seit

  • Letzter Besuch

Posts erstellt von magnaparva

  1. @GoranP, I am glad to hear I was not the only one with this problem, I immediately assumed it was something I was doing wrong with my code...

     

    @borg I don't know when you generated the images on your website, but the automated configuration process might have been having issues longer than you think. The MAC address for the screenshot on

    https://www.tinkerforge.com/en/doc/Hardware/Master_Extensions/Ethernet_Extension.html#ethernet-configuration has the same 02:A0:00 ending.

  2. I have been having a lot of problems getting the Ethernet Extensions to work reliable when used together. My test configuration consists of 3 master bricks, 2 Ethernet Extensions, 1 Raspberry Pi running brickd and a Windows PC running C#. The Windows PC is running the latest C# bindings and code very much from the Rugged Approach tutorial (full code at end).

     

    TEST 1: Connecting to any IPConnection individually (by commenting out the Connect command for the other two) works very reliably and takes consistently about 0.05s.

     

    TEST 2: Connecting to the Raspberry Pi and any one Ethernet Extension work equally reliably, and also takes about 0.05s to connect.

     

    TEST 3: Connecting to the Raspberry Pi, one of the stacks to my Windows PC running a local brickd and USB connection (changing _HOST to be 127.0.0.1) and any one Master Extension work equally reliably as TEST 2.

     

    TEST 4: Connecting to the Raspberry Pi and two Ethernet Extensions works only roughly 65% of the time (though somewhat oddly often takes 9.06s). When it fails it seems to consistently fail with the last stack to be called (i.e. if I change the order that the _TFStack.Connect commands are called it is the last one which will fail).

     

    Please find my code below, note that that there is a Authenticate command at the end and _HOST which will have to be adjusted for your setup (and I know the code is not particularly clean, just hacked together for testing purposes).

     

    Has anyone else had any problems connecting to multiple Ethernet Extensions?

     

    using Tinkerforge;
    using System.Diagnostics;
    
    public class EthernetMasterTesting
    {
        private const string _HOST1 = "192.168.1.1";
        private const string _HOST2 = "192.168.1.2";
        private const string _HOST3 = "192.168.1.3";
    
        private const int _PORT = 4223;
    
        private static IPConnection _TFStack1 = null;
        private static IPConnection _TFStack2 = null;
        private static IPConnection _TFStack3 = null;
    
        static void Main()
        {
            long totalTime = 0;
            int numberOfTests = 5;
            for (int i = 0; i < numberOfTests; i++)
            {
                if (_TFStack1 == null)
                {
                    _TFStack1 = new IPConnection();
                    _TFStack1.Connected += ConnectedCB;
                    _TFStack1.Disconnected += DisconnectedCB;
                    _TFStack1.EnumerateCallback += EnumerateCB1;
                }
    
                if (_TFStack2 == null)
                {
                    _TFStack2 = new IPConnection();
                    _TFStack2.Connected += ConnectedCB;
                    _TFStack2.Disconnected += DisconnectedCB;
                    _TFStack2.EnumerateCallback += EnumerateCB2;
                }
    
                if (_TFStack3 == null)
                {
                    _TFStack3 = new IPConnection();
                    _TFStack3.Connected += ConnectedCB;
                    _TFStack3.Disconnected += DisconnectedCB;
                    _TFStack3.EnumerateCallback += EnumerateCB3;
                }
    
                System.Console.WriteLine("Connect Requested");
                Stopwatch sw = new Stopwatch();
                sw.Start();
                try
                {
                    _TFStack1.Connect(_HOST1, _PORT);
                }
                catch (System.Exception e)
                {
                    System.Console.WriteLine("Could not connect 1");
                    System.Console.WriteLine(e.Source + " : " + e.Message);
                }
                try
                {
                    _TFStack2.Connect(_HOST2, _PORT);
                }
                catch (System.Exception e)
                {
                    System.Console.WriteLine("Could not connect 2");
                    System.Console.WriteLine(e.Source + " : " + e.Message);
                }
                try
                {
                    _TFStack3.Connect(_HOST3, _PORT);
                }
                catch (System.Exception e)
                {
                    System.Console.WriteLine("Could not connect 3");
                    System.Console.WriteLine(e.Source + " : " + e.Message);
                }
                
                sw.Stop();
                System.Console.WriteLine("Took " + sw.ElapsedMilliseconds / 1000.0 + "s to connect stacks.");
                totalTime += sw.ElapsedMilliseconds;
    
                System.Threading.Thread.Sleep(1000);
    
                if (_TFStack1.GetConnectionState() == IPConnection.CONNECTION_STATE_CONNECTED)
                    _TFStack1.Disconnect();
    
                if (_TFStack2.GetConnectionState() == IPConnection.CONNECTION_STATE_CONNECTED)
                    _TFStack2.Disconnect();
    
                if (_TFStack3.GetConnectionState() == IPConnection.CONNECTION_STATE_CONNECTED)
                    _TFStack3.Disconnect();
            }
            System.Console.WriteLine("Average Time to connect stacks " + totalTime / (numberOfTests * 1000.0));
            System.Console.WriteLine("Press enter to exit");
            System.Console.ReadLine();
        }
    
        private static void EnumerateCB3(IPConnection sender, string uid, string connectedUid, char position, short[] hardwareVersion, short[] firmwareVersion, int deviceIdentifier, short enumerationType)
        {
            if (enumerationType == IPConnection.ENUMERATION_TYPE_CONNECTED ||
               enumerationType == IPConnection.ENUMERATION_TYPE_AVAILABLE)
            {
                if (deviceIdentifier == BrickMaster.DEVICE_IDENTIFIER)
                {
                    System.Console.WriteLine("Brick connected " + uid + " on Stack 3");
                }
            }
        }
    
        private static void EnumerateCB2(IPConnection sender, string uid, string connectedUid, char position, short[] hardwareVersion, short[] firmwareVersion, int deviceIdentifier, short enumerationType)
        {
            if (enumerationType == IPConnection.ENUMERATION_TYPE_CONNECTED ||
               enumerationType == IPConnection.ENUMERATION_TYPE_AVAILABLE)
            {
                if (deviceIdentifier == BrickMaster.DEVICE_IDENTIFIER)
                {
                    System.Console.WriteLine("Brick connected " + uid + " on Stack 2");
                }
            }
        }
    
        static void EnumerateCB1(IPConnection sender, string UID, string connectedUID,
                                char position, short[] hardwareVersion,
                                short[] firmwareVersion, int deviceIdentifier,
                                short enumerationType)
        {
            if (enumerationType == IPConnection.ENUMERATION_TYPE_CONNECTED ||
               enumerationType == IPConnection.ENUMERATION_TYPE_AVAILABLE)
            {
                if (deviceIdentifier == BrickMaster.DEVICE_IDENTIFIER)
                {
                    System.Console.WriteLine("Brick connected " + UID + " on Stack 1");
                }
            }
        }
    
        private static void DisconnectedCB(IPConnection sender, short disconnectReason)
        {
            System.Console.WriteLine("Disconnected");
        }
    
        static void ConnectedCB(IPConnection sender, short connectReason)
        {
            try
            {
                sender.Authenticate("SUPERSECRETPASSWORD");
                sender.Enumerate();
            }
            catch (System.Exception e)
            {
                System.Console.WriteLine("After connected failed to authenticate or enumerate");
                System.Console.WriteLine(e.Source + " : " + e.Message);
            }
        }
    }
    

  3. I am attempting to compile the C# bindings in a Ubuntu 16.0 environment using mono compiler version Stable 4.8.0.495/e4a3cf3.

     

    Reverting to csharp-2.1.12 git tag and running the following commands:

    cd ~/tf/generators/csharp
    python generate_csharp_bindings.py && python generate_csharp_zip.py

     

    I receive the following xbuild compile errors:

    Project "/tmp/generator/csharp/source/Tinkerforge/Tinkerforge.csproj" (default target(s)):
    Target PrepareForBuild:
    	Configuration: Release Platform: AnyCPU
    	Created directory "bin/Release/"
    	Created directory "obj/Release/"
    Target ResolveNuGetPackageAssets:
    : error : Your project is not referencing the ".NETFramework,Version=v4.0" framework. Add a reference to ".NETFramework,Version=v4.0" in the "frameworks" section of your project.json, and then re-run NuGet restore.
    Task "ResolveNuGetPackageAssets" execution -- FAILED
    Done building target "ResolveNuGetPackageAssets" in project "/tmp/generator/csharp/source/Tinkerforge/Tinkerforge.csproj".-- FAILED
    Done building project "/tmp/generator/csharp/source/Tinkerforge/Tinkerforge.csproj".-- FAILED
    
    Build FAILED.
    Errors:
    
    /tmp/generator/csharp/source/Tinkerforge/Tinkerforge.csproj (default targets) ->
    /usr/lib/mono/xbuild/Microsoft/NuGet/Microsoft.NuGet.targets (ResolveNuGetPackageAssets target) ->
    
    : error : Your project is not referencing the ".NETFramework,Version=v4.0" framework. Add a reference to ".NETFramework,Version=v4.0" in the "frameworks" section of your project.json, and then re-run NuGet restore.
    
     0 Warning(s)
     1 Error(s)

     

    I assumed the issue was with the project.json requesting invalid dependencies, though that all looks as fairly minimal and correct. Doing some research it seems that the project.lock.json file is generated anyway by the project.json file so I thought I would try simply deleting it, and it now compiles fine. The easiest way I found to remove it was to delete line 77 from generate_csharp_zip.py as well as deleting the file.

     

    Is the project.lock.json actually required?

  4. Ah yes, sorry, I meant to say R8 and R10 in my last post and should have multiplied the resistor by 6 rather than divide.

     

    If I change both R8 and R10 to be 33k (e.g. http://uk.farnell.com/1717610) and leave R13 and R14 at 280k, I should be able to get a range of +-5.09V (at the input to the U1B) to provide the required 0.6V the ADC0 net.

     

    Will I then need to recalibrate U4? to convert the reading would it be as simple as dividing the result from the API by 7.021 (based on 35.745/5.091)?

  5. Thanks for the speedy reply!

    I am measuring a 0-5V signal, where ideally I would like to achieve an accuracy of +-1mV.

    If I could get the range down to a 6th of current, that would give +-5.83V range which assuming the accuracy would be also be 6 times improved would work for our application.

    Would it be as simple as exchanging R8 and R10 to 4k7/6 resistor? Going for something readily available, like a 787 ohm (e.g. http://uk.farnell.com/1752470)?

     

    Edit: Resistor labels changed to read R8 and R10

  6. I don't understand the technical specifications given for the Analog In V2.0 Bricklet 2.0.

    It gives a voltage range of 0-42 VDC at 1mV step, but a 12bit resolution at 10mV step.

    How can I achieve the 1mV resolution? As I cannot see any software adjustable resistors (as with the V1.0 bricklet) I don't understand how I can achieve any better resolution than the 42.9/2^12 = 10.5mV.

×
×
  • Neu erstellen...