conversion lin commands into an analog signal
Moderator: Benj
-
- Posts: 15
- Joined: Tue May 22, 2018 10:02 am
conversion lin commands into an analog signal
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.
-
- Posts: 15
- Joined: Tue May 22, 2018 10:02 am
Re: conversion lin commands into an analog signal
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
-
- Valued Contributor
- Posts: 1208
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
Re: conversion lin commands into an analog signal
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
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
-
- Posts: 15
- Joined: Tue May 22, 2018 10:02 am
Re: conversion lin commands into an analog signal
thanks for the links. I will study. I have problems with the LIN macro itself. more precisely, his teams. I will report on progress
-
- Posts: 15
- Joined: Tue May 22, 2018 10:02 am
Re: conversion lin commands into an analog signal
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.
-
- Valued Contributor
- Posts: 1208
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
Re: conversion lin commands into an analog signal
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: You can read / write data to this using an index operator:
or
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:
Of course you could write (in calculation boxes):
or:
- 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
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: You can read / write data to this using an index operator:
Code: Select all
a = data[0]
Code: Select all
data[0] = 1
This lends itself particularly well to handling the data in a loop - for example to clear the data:
Of course you could write (in calculation boxes):
Code: Select all
a= 0
b = 0
c = 0
d = 0
e = 0
f = 0
Code: Select all
data[0] = 0
data[1] = 0
..
data[5] = 0
Search for flowcode arrays - there are lots of examples.
Martin
-
- Posts: 15
- Joined: Tue May 22, 2018 10:02 am
Re: conversion lin commands into an analog signal
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"
-
- Valued Contributor
- Posts: 1208
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
Re: conversion lin commands into an analog signal
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
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
-
- Valued Contributor
- Posts: 1208
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
Re: conversion lin commands into an analog signal
Oops, just noticed I didn't post the link
viewtopic.php?f=26&t=20701
How goes your progress with this?

viewtopic.php?f=26&t=20701
How goes your progress with this?
-
- Posts: 15
- Joined: Tue May 22, 2018 10:02 am
Re: conversion lin commands into an analog signal
Unfortunately I could not see the project because it is installed FC 5
-
- Valued Contributor
- Posts: 1208
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
Re: conversion lin commands into an analog signal
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)
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
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
-
- Posts: 15
- Joined: Tue May 22, 2018 10:02 am
Re: conversion lin commands into an analog signal
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"?
-
- Posts: 15
- Joined: Tue May 22, 2018 10:02 am
-
- Valued Contributor
- Posts: 1208
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
Re: conversion lin commands into an analog signal
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
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
-
- Posts: 15
- Joined: Tue May 22, 2018 10:02 am
Re: conversion lin commands into an analog signal
I can't figure out which component the "circular buffer"macro refers to. I didn't find one of those.
-
- Valued Contributor
- Posts: 1208
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
Re: conversion lin commands into an analog signal
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 Here RXRecieve (sic) is used as a flag to let the main part of the program know that there is data to process.
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 Here RXRecieve (sic) is used as a flag to let the main part of the program know that there is data to process.