Re: [Emc-developers] writing new firmware to read yaskawa absolute encoder

2018-03-23 Thread Thắng Lê
2018-03-23 21:14 GMT+07:00 Peter C. Wallace :

> On Fri, 23 Mar 2018, Th?ng L? wrote:
>
> Date: Fri, 23 Mar 2018 16:04:47 +0700
>> From: "[UTF-8] Th?ng L?" 
>> Reply-To: EMC developers 
>> To: EMC developers 
>> Subject: Re: [Emc-developers] writing new firmware to read yaskawa
>> absolute
>> encoder
>>
>> i guess i cant contact UART on mesa 5i25 by linuxcnc, just only can get
>> data from FIFO. I found a way to solve this problem without touchich
>> uart.c
>> source but it's not complete.
>>
>> in 8 bytes serial, the first data is "P" (80 in hexa) and last bytes is
>> "CR" (13 in hexa).
>>
>> if i read FIFO data every 1 ms ( speed to read 1 bytes at 9600 baudrate
>> and
>> 10 bit frames), function will stop reading when it sees 80 ( or 13) but i
>> get only 1 byte that is 80 (or 13). I guess RX FIFO is cleared everytime i
>> read but i didnt find where that function is in:
>>
>
>
> When you start looking for the serial data do you clear the FIFO first?
> (writing to the FIFO count register clears the FIFO)
>
No, i didnt, ,the hm2_uart_read doesnt have function to clear RX_FIFO. It
doesnt contain function:
hm2->llio->write(hm2->llio, inst->rx_fifo_count_addr, , sizeof(u32));
I wonder why do we need to clear it, it already clear in setup function. I
will try add this function in HAL component, if it is impossible i probably
modify low level read function


> Does the low level read function wait for data? (FIFO count not 0)
>
Yes, it has a function:
hm2->llio->read(hm2->llio, hm2->uart.instance[inst].rx_fifo_count_addr , ,
sizeof(u32));

If you dont do these things its not likely you will get usable data



> Also you should read _all_ characters in the FIFO every ms
> (meaning you must read the FIFO count first to determine how many to read)

Exactly i got all correct data if the channel A of encoder back idle state
after send 8 bytes serial data.




2018-03-23 22:23 GMT+07:00 Gene Heskett :

> On Friday 23 March 2018 05:04:47 Thắng Lê wrote:
>
> > i guess i cant contact UART on mesa 5i25 by linuxcnc, just only can
> > get data from FIFO. I found a way to solve this problem without
> > touchich uart.c source but it's not complete.
> >
> > in 8 bytes serial, the first data is "P" (80 in hexa) and last bytes
> > is "CR" (13 in hexa).
> >
> > if i read FIFO data every 1 ms ( speed to read 1 bytes at 9600
> > baudrate and 10 bit frames), function will stop reading when it sees
> > 80 ( or 13) but i get only 1 byte that is 80 (or 13). I guess RX FIFO
> > is cleared everytime i read but i didnt find where that function is
> > in:
> 9600 baud? Run that up to as fast as you can. At 9600, you'll be watching
> grass grow. 256k or better.


No, i cant change baudrate because it's abs_encoder baudrate


> > > --
> > > Lê Thắng
> > > Phone: (+84) 1222443855
> > > Email: lethang12...@gmail.com
>
>
>
> --
> Cheers, Gene Heskett
> --
> "There are four boxes to be used in defense of liberty:
>  soap, ballot, jury, and ammo. Please use in that order."
> -Ed Howdershelt (Author)
> Genes Web page 
>
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Emc-developers mailing list
> Emc-developers@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/emc-developers
>

I also thank you very much, just a bit more before finish this project

-- 
Lê Thắng
Phone: (+84) 1222443855
Email: lethang12...@gmail.com
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Emc-developers mailing list
Emc-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-developers


Re: [Emc-developers] writing new firmware to read yaskawa absolute encoder

2018-03-23 Thread Peter C. Wallace

On Fri, 23 Mar 2018, Peter C. Wallace wrote:


Date: Fri, 23 Mar 2018 07:14:38 -0700 (PDT)
From: Peter C. Wallace 
Reply-To: EMC developers 
To: EMC developers 
Subject: Re: [Emc-developers] writing new firmware to read yaskawa absolute
encoder

On Fri, 23 Mar 2018, Th?ng L? wrote:


Date: Fri, 23 Mar 2018 16:04:47 +0700
From: "[UTF-8] Th?ng L?" 
Reply-To: EMC developers 
To: EMC developers 
Subject: Re: [Emc-developers] writing new firmware to read yaskawa absolute
encoder

i guess i cant contact UART on mesa 5i25 by linuxcnc, just only can get
data from FIFO. I found a way to solve this problem without touchich uart.c
source but it's not complete.

in 8 bytes serial, the first data is "P" (80 in hexa) and last bytes is
"CR" (13 in hexa).

if i read FIFO data every 1 ms ( speed to read 1 bytes at 9600 baudrate and
10 bit frames), function will stop reading when it sees 80 ( or 13) but i
get only 1 byte that is 80 (or 13). I guess RX FIFO is cleared everytime i
read but i didnt find where that function is in:



When you start looking for the serial data do you clear the FIFO first?
(writing to the FIFO count register clears the FIFO)

Does the low level read function wait for data? (FIFO count not 0)

If you dont do these things its not likely you will get usable data



Also you should read _all_ characters in the FIFO every ms
(meaning you must read the FIFO count first to determine how many to read)

Peter Wallace
Mesa Electronics


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Emc-developers mailing list
Emc-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-developers


Re: [Emc-developers] writing new firmware to read yaskawa absolute encoder

2018-03-23 Thread Thắng Lê
i guess i cant contact UART on mesa 5i25 by linuxcnc, just only can get
data from FIFO. I found a way to solve this problem without touchich uart.c
source but it's not complete.

in 8 bytes serial, the first data is "P" (80 in hexa) and last bytes is
"CR" (13 in hexa).

if i read FIFO data every 1 ms ( speed to read 1 bytes at 9600 baudrate and
10 bit frames), function will stop reading when it sees 80 ( or 13) but i
get only 1 byte that is 80 (or 13). I guess RX FIFO is cleared everytime i
read but i didnt find where that function is in:

https://github.com/araisrobo/linuxcnc/blob/master/src/hal/drivers/mesa-hostmot2/uart.c#L267

So I "read" data in RX FIFO as fast as time to send/receive 8 bytes data,
function will stop when it sees  80 . For UART has 9600 baudrate, 10
bit/byte and 8 bytes. My formula to caculate thread :
100us/bit * 10bit/byte * 8bytes * 2 ( for tx and rx).
This time i get all data but sometimes lost last bytes.

Below is my modified mesa_uart.comp file.

2018-03-23 10:47 GMT+07:00 Thắng Lê :

> i read uart.c that is written by Andy and found some lines that maybe can
> clear FIFO:
>
> https://github.com/araisrobo/linuxcnc/blob/master/src/hal/
> drivers/mesa-hostmot2/uart.c#L164-L165
>
> the data receive RX at:
> https://github.com/araisrobo/linuxcnc/blob/master/src/hal/
> drivers/mesa-hostmot2/uart.c#L296-L332
>
> When you said "disable RX", does that mean disable RX on 5i25 or RX on
> this driver?
>
> 2018-03-22 10:18 GMT+07:00 Thắng Lê :
>
>> i 'm looking at* hm2_uart_setup,* the rx_mode describe:
>> *   Bit 0* = FalseStart bit Status, 1 = false start bit detected
>>*Bit 1* = OverRun Status, 1 = overrun condition detected (no
>> valid stop bit)
>>*Bit 2* = RXMaskEnable, 1= enable RXMask for half duplex
>> operation, 0 = ingore RXMask
>>*Bit 4* = FIFOError, indicates that a host read has attemped to
>> read more data than available. (mainly for driver debugging)
>>*Bit 5* = LostDataError, indicates that data was received with no
>> room in FIFO,
>> *   Bit 6* = RXMask, RO RXMASK status
>> *   Bit 7* = FIFO Has Data
>>
>> I'm not very clearly understand when i read it,i dont see how to clear
>> FIFO or disable RX from these 7 bits. I guess u mention pktuart, right?
>>
>>
>>
>> 2018-03-22 0:28 GMT+07:00 Peter C. Wallace :
>>
>>> On Wed, 21 Mar 2018, Th?ng L? wrote:
>>>
>>> Date: Wed, 21 Mar 2018 15:20:12 +0700
 From: "[UTF-8] Th?ng L?" 
 Reply-To: EMC developers 
 To: EMC developers 
 Subject: Re: [Emc-developers] writing new firmware to read yaskawa
 absolute
 encoder

 i'm using mesa_uart to read serial data but i have a issue. Sometimes,

>>> after sending 8 bytes, the  phase A isnt come back idle state-5V state
>>> (it
>>> keeps 0V state).  This mean uart is still getting data after first 8
>>> bytes,then
>>> the UART data shows me rx-bytes = 16, all  rx-data = 0.
>>>
>>>
>>>
>>>
>>>
>>> Is mesa_uart posible to limit the number bytes UART read?
>>>
>>>
>>> No, but this is expected if the input is driven low after the data
>>> you must only clear the UART/FIFO when the data line is idle
>>>
>>> You can disable RX if you know when the input data will become invalid
>>>
>>> (you would also expect to see the framing error bit set in this
>>> circumstance)
>>>
>>>
>>>
>>> 2018-03-16 23:52 GMT+07:00 Peter C. Wallace :
>>>
>>> On Fri, 16 Mar 2018, Th?ng L? wrote:

 Date: Fri, 16 Mar 2018 23:43:49 +0700

> From: "[UTF-8] Th?ng L?" 
> Reply-To: EMC developers 
> To: EMC developers 
> Subject: Re: [Emc-developers] writing new firmware to read yaskawa
> absolute
> encoder
>
> ah, i understood what you mean. thank you very much
>
>
 2018-03-16 23:30 GMT+07:00 andy pugh :

 On 16 March 2018 at 16:27, Thng L 
 wrote:

> > this is a great idea but how can i right-shift the data? Both your
> way
> and
> > Peter's way seem have to touch UART  source
>
> No, you can shift the raw data in the HAL component that interprets the
> data.
>
> --
> atp
> "A motorcycle is a bicycle with a pandemonium attachment and is
> designed for the especial use of mechanical geniuses, daredevils and
> lunatics."
>  George Fitch, Atlanta Constitution Newspaper, 1916
>
>
 Actually theres no shifting involved, only manipulating bit 7 of the
 8 bit data

 Peter Wallace
 Mesa Electronics

 
 --
 Check out the vibrant tech community on one of the