Jump to content
  • 0

Differential signals


bryan78

Question

It would be nice to have a feature to output a differential signal to replicate rs485.  I find myself often having to generate a pattern on one pin and then the inverse on another to drive a differential signal.   It would also be nice if this was available under protocols.

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Hi @bryan78

It can be done using DIOs 0/3.3V, just select for both Idle 0. Here I used idle 1 for A to be able to decode it as nondifferential.
Also see the 2nd method using Wavegen up to +/-5V

image.png

const tx = "hello";
const hz = 9600;
var rga = [], rgb = [];
for(var i = 0; i < tx.length; i++){
    rga.push(0); rgb.push(1); // start
    for(var j = 0; j < 8; j++){
        var c = 1&(tx.charCodeAt(i)>>j);
        rga.push(c); rgb.push(1-c);
    }
    rga.push(1); rgb.push(0); // stop
}
Patterns.Channels.DIO0.custom = rga;
Patterns.Channels.DIO1.custom = rgb;
Patterns.Channels.DIO0.Frequency.value = hz;
Patterns.Channels.DIO1.Frequency.value = hz;
Patterns.States.Run.value = 10.0*i/hz;
Patterns.States.Repeat.value = 1;
Patterns.run();

image.png

const tx = "hello";
const hz = 9600;
var rga = [], rgb = [];
for(var i = 0; i < tx.length; i++){
    rga.push(-1); rgb.push(1); // start
    for(var j = 0; j < 8; j++){
        var c = 1&(tx.charCodeAt(i)>>j);
        rga.push(c?1:-1); rgb.push(c?-1:1);
    }
    rga.push(1); rgb.push(-1); // stop
}
Wavegen.Custom.set("A", rga);
Wavegen.Custom.set("B", rgb);
Wavegen.Channel1.Custom.SampleRate.value = hz;
Wavegen.Channel2.Custom.SampleRate.value = hz;
Wavegen.States.Run.value = 10.0*i/hz;
Wavegen.States.Repeat.value = 1;
Wavegen.run();

 

Link to comment
Share on other sites

  • 0

Hi All.  I wonder if relevant Workspace can be included in posts like this.  I get the sense of what is happening here and can certainly copy and paste the script given the posted script text, but I'm having difficulty duplicating the Wavegen configuration and as a beginner feel like I can save a bunch of time and learn more if there was a workspace ?

Thank you,  Sven  

Link to comment
Share on other sites

  • 0

Didn't realize that scripts will populate much of the Wavegen config.  Initially I tried creating the Wavegen configuration details before executing the script and did something that prevented it from working, but just tried again doing much less and it worked.  Sorry for noise. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...