conversion lin commands into an analog signal

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

leha_m1986
Posts: 11
Joined: Tue May 22, 2018 10:02 am
Contact:

conversion lin commands into an analog signal

Postby leha_m1986 » Fri Feb 01, 2019 1:17 pm

Hello! help please! there are two buttons on the steering wheel of the car that communicate via the LIN interface. it is necessary for their commands to translate the outputs of the microcontroller in different States. On LIN nothing useful not found. Tell me where to start. There is no description of the Lin macro anywhere either.

mnf
Valued Contributor
Valued Contributor
Posts: 540
Joined: Wed May 31, 2017 11:57 am
Has thanked: 53 times
Been thanked: 300 times
Contact:

Re: conversion lin commands into an analog signal

Postby mnf » Fri Feb 01, 2019 7:18 pm


leha_m1986
Posts: 11
Joined: Tue May 22, 2018 10:02 am
Contact:

Re: conversion lin commands into an analog signal

Postby leha_m1986 » Sat Feb 02, 2019 7:18 am

I've studied the Protocol description. and how to implement it in flowcode? I'd like a description of the macro, or an example of some sort

mnf
Valued Contributor
Valued Contributor
Posts: 540
Joined: Wed May 31, 2017 11:57 am
Has thanked: 53 times
Been thanked: 300 times
Contact:

Re: conversion lin commands into an analog signal

Postby mnf » Sat Feb 02, 2019 7:53 am

Sorry, misunderstood your question
There seems to be little information on the matrix site.
Try viewtopic.php?f=22&t=4566
Which has some (old) examples. The Lin course notes at https://www.matrixtsl.com/datasheets/EB929-82-03.pdf seems to stop at 3 although the index suggests more would be available. The topic here: http://www.matrixtsl.com/mmforums/viewtopic.php?t=16395 peters out as well without any real info, perhaps someone could comment if there is any progress.

Martin

leha_m1986
Posts: 11
Joined: Tue May 22, 2018 10:02 am
Contact:

Re: conversion lin commands into an analog signal

Postby leha_m1986 » Sat Feb 02, 2019 8:05 am

thanks for the links. I will study. I have problems with the LIN macro itself. more precisely, his teams. I will report on progress

leha_m1986
Posts: 11
Joined: Tue May 22, 2018 10:02 am
Contact:

Re: conversion lin commands into an analog signal

Postby leha_m1986 » Sun Feb 03, 2019 5:54 am

By studying the LIN Protocol, it was possible to get commands in the UART. The teams will manage the port. 50 04 68 3b 01 06-high level briefly, 50 04 68 3B 11 16 - high level permanently, 50 04 68 3B 21 26-low level. Could you tell me how to organize it? I so understand it is necessary to use "arrays"? I've never worked with them. And forum problem to look for, how to communicate with You through an interpreter.

mnf
Valued Contributor
Valued Contributor
Posts: 540
Joined: Wed May 31, 2017 11:57 am
Has thanked: 53 times
Been thanked: 300 times
Contact:

Re: conversion lin commands into an analog signal

Postby mnf » Sun Feb 03, 2019 10:49 pm

Can you post your current code - and a bit more description of what you are trying to do.

Arrays are a very useful feature in programming languages - well worth the effort to get to grips with them. You've probably used them already (for example strings are an array of characters)

As a simple example - say you have six bytes to read (as per your example) - rather than having six variables (a,b,c,d,e,f) - you'd define an array:
variable.JPG
variable.JPG (29.66 KiB) Viewed 2142 times


You can read / write data to this using an index operator:

Code: Select all

a = data[0]

or

Code: Select all

data[0] = 1

For example. An important point to notice here is that the first index is 0. For a 6 byte array the index value will be 0..5 (this is true in most (but not quite all programming languages) - but get the hang of this idea, and you will find arrays easy to use..

This lends itself particularly well to handling the data in a loop - for example to clear the data:

clear.JPG
clear.JPG (15.44 KiB) Viewed 2142 times


Of course you could write (in calculation boxes):

Code: Select all

a= 0
b = 0
c = 0
d = 0
e = 0
f = 0

or:

Code: Select all

data[0] = 0
data[1] = 0
..
data[5] = 0
- but things can rapidly become hard to manage (imagine data is 512 bytes for instance)

Search for flowcode arrays - there are lots of examples.

Martin
These users thanked the author mnf for the post:
medelec35 (Sat Feb 16, 2019 11:10 am)
Rating: 5.26%
 

leha_m1986
Posts: 11
Joined: Tue May 22, 2018 10:02 am
Contact:

Re: conversion lin commands into an analog signal

Postby leha_m1986 » Mon Feb 04, 2019 7:15 am

Dear Martin! About arrays I read, but never worked with them. I can't figure out how to take an array from UART. since the UART only accepts "BYTE"

mnf
Valued Contributor
Valued Contributor
Posts: 540
Joined: Wed May 31, 2017 11:57 am
Has thanked: 53 times
Been thanked: 300 times
Contact:

Re: conversion lin commands into an analog signal

Postby mnf » Tue Feb 05, 2019 10:34 pm

Try the example here - reads input from UART into a circular buffer and then copies it into a 6 byte array..

It uses the UART interrupt to read the data (a byte at a time) and copies to an array to just deal with it when sufficient input is received.

Martin

mnf
Valued Contributor
Valued Contributor
Posts: 540
Joined: Wed May 31, 2017 11:57 am
Has thanked: 53 times
Been thanked: 300 times
Contact:

Re: conversion lin commands into an analog signal

Postby mnf » Sun Feb 10, 2019 2:59 pm

Oops, just noticed I didn't post the link :oops:

viewtopic.php?f=26&t=20701

How goes your progress with this?

leha_m1986
Posts: 11
Joined: Tue May 22, 2018 10:02 am
Contact:

Re: conversion lin commands into an analog signal

Postby leha_m1986 » Tue Feb 12, 2019 2:23 pm

Unfortunately I could not see the project because it is installed FC 5

mnf
Valued Contributor
Valued Contributor
Posts: 540
Joined: Wed May 31, 2017 11:57 am
Has thanked: 53 times
Been thanked: 300 times
Contact:

Re: conversion lin commands into an analog signal

Postby mnf » Tue Feb 12, 2019 7:34 pm

I've added images of the three main macros (the others won't help unless you have a MaxM LED setup and just deal with i2c comms to the LED array)

moodlight.zip
(143.38 KiB) Downloaded 44 times

The interrupt adds any input from UART (in this case connected to a Bluetooth receiver) - to a circular buffer, and the main program loop shifts these characters into an array - looking for a valid command (here a 3 byte command and a 3 byte integer value (actually 0..255)) There a two main arrays (rx and cmds) - testcmd does a bit more processing (checks if the first 3 characters represent a valid command and convert the second 3 characters into an integer) - it's a bit more complicated than it needs to be (it would have been easier to use single letter commands for instance) - because I wanted to try out a couple of ideas.

Hope it is of some help.

Martin

leha_m1986
Posts: 11
Joined: Tue May 22, 2018 10:02 am
Contact:

Re: conversion lin commands into an analog signal

Postby leha_m1986 » Wed Feb 13, 2019 7:47 am

I can't find the second component of the macro. I don't. And in the first I have to take CHAR and collapse the variable "C"?

leha_m1986
Posts: 11
Joined: Tue May 22, 2018 10:02 am
Contact:

Re: conversion lin commands into an analog signal

Postby leha_m1986 » Fri Feb 15, 2019 7:24 pm

forgot to say all those commands in HEX

mnf
Valued Contributor
Valued Contributor
Posts: 540
Joined: Wed May 31, 2017 11:57 am
Has thanked: 53 times
Been thanked: 300 times
Contact:

Re: conversion lin commands into an analog signal

Postby mnf » Fri Feb 15, 2019 10:37 pm

The commands in hex are just an ASCII representation of a 3 character command ("RED", "GRN", "BLU" and "PRG") - here saved to a 4 byte value.

Take a look at ASCII (try https://en.wikipedia.org/wiki/ASCII)

But basically each character can be represented as one byte (8 bits - 0..255) - so in the above example 'c' is a byte variable used to handle each character received.
Used to 'take apart' strings etc and examine each character in turn...

Martin

leha_m1986
Posts: 11
Joined: Tue May 22, 2018 10:02 am
Contact:

Re: conversion lin commands into an analog signal

Postby leha_m1986 » Sat Feb 16, 2019 7:33 am

I can't figure out which component the "circular buffer"macro refers to. I didn't find one of those.

mnf
Valued Contributor
Valued Contributor
Posts: 540
Joined: Wed May 31, 2017 11:57 am
Has thanked: 53 times
Been thanked: 300 times
Contact:

Re: conversion lin commands into an analog signal

Postby mnf » Sat Feb 16, 2019 9:33 am

I don't have v5 to check - it's in storage now....

Check here: http://www.matrixtsl.com/mmforums/viewt ... 84&#p33484

Where Ben gives some source for a circular buffer.

Might be quite a bit of work!

As an alternative - in your receive interrupt just use a receive string - and assign the data to a string
rxint.JPG
rxint.JPG (9.96 KiB) Viewed 1917 times


Here RXRecieve (sic) is used as a flag to let the main part of the program know that there is data to process.